mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Summary: Adds debug visualizer to render Collider and CollidableComponents. You can choose their color in the entity defition even. Tweaked how HitboxComponent stores its AABB, for performance. (Forgive me, I lost control!) Fixed hitbox calculation that was shifting them down and to the right. Collidables still seem to prefer going by the sprite size instead of looking for a HitboxComponent. That will need to be fixed later. As will the offset of the player sprite. Test Plan: Hit F4 and caress the table. Reviewers: #ss14_developers, volundr- Reviewed By: #ss14_developers, volundr- Projects: #space_station_14 Differential Revision: http://phab.nexisonline.net/D40
56 lines
1.8 KiB
C#
56 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using GameObject;
|
|
using SS13_Shared.GO;
|
|
using SS13_Shared.GO.Component.Hitbox;
|
|
|
|
namespace SGO
|
|
{
|
|
public class HitboxComponent : Component
|
|
{
|
|
public RectangleF AABB { get; set; }
|
|
|
|
public HitboxComponent()
|
|
{
|
|
Family = ComponentFamily.Hitbox;
|
|
AABB = new RectangleF();
|
|
}
|
|
|
|
public override ComponentState GetComponentState()
|
|
{
|
|
return new HitboxComponentState(AABB);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set parameters :)
|
|
/// </summary>
|
|
/// <param name="parameter"></param>
|
|
public override void SetParameter(ComponentParameter parameter)
|
|
{
|
|
//base.SetParameter(parameter);
|
|
switch (parameter.MemberName)
|
|
{
|
|
case "SizeX":
|
|
var width = parameter.GetValue<float>();
|
|
AABB = new RectangleF(AABB.Left + (AABB.Width - width) / 2f, AABB.Top, width, AABB.Height);
|
|
break;
|
|
case "SizeY":
|
|
var height = parameter.GetValue<float>();
|
|
AABB = new RectangleF(AABB.Left, AABB.Top + (AABB.Height - height) / 2f, AABB.Width, height);
|
|
break;
|
|
case "OffsetX":
|
|
var x = parameter.GetValue<float>();
|
|
AABB = new RectangleF(x - AABB.Width / 2f, AABB.Top, AABB.Width, AABB.Height);
|
|
break;
|
|
case "OffsetY":
|
|
var y = parameter.GetValue<float>();
|
|
AABB = new RectangleF(AABB.Left, y - AABB.Height / 2f, AABB.Width, AABB.Height);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|