Action Bar (WIP)
Refactor item instance to use DatabaseLink Labels now pop up when aiming at loot Yeeted HUD trigger group UI into the abyss Created rebindable action bar (missing: assigning actions) Created Consumable Items Refactored behaviors to work on consumable items Implemented Velocity Conversion Behavior
This commit is contained in:
parent
282035dd25
commit
4489b18452
217 changed files with 5105 additions and 5703 deletions
|
|
@ -13,28 +13,94 @@ using Unity.Mathematics;
|
|||
using static Unity.Mathematics.math;
|
||||
using static Unity.Mathematics.noise;
|
||||
|
||||
public interface IBehavior
|
||||
public abstract class Behavior
|
||||
{
|
||||
bool Execute(float dt);
|
||||
BehaviorData Data { get; }
|
||||
public BehaviorData Data { get; }
|
||||
public EquippedItem Item { get; }
|
||||
private ConsumableItemEffect Consumable { get; }
|
||||
protected ItemManager ItemManager { get; }
|
||||
|
||||
protected Entity Entity => Item?.Entity ?? Consumable.Entity;
|
||||
public float Temperature => Item?.Temperature ?? Consumable.Entity.MaxTemp;
|
||||
|
||||
public float3 Direction
|
||||
{
|
||||
get
|
||||
{
|
||||
if(Item != null)
|
||||
{
|
||||
var hardpoint = Entity.Hardpoints[Item.Position.x, Item.Position.y];
|
||||
if (hardpoint != null && Entity.HardpointTransforms.ContainsKey(hardpoint))
|
||||
{
|
||||
return normalize(Entity.HardpointTransforms[hardpoint].direction);
|
||||
}
|
||||
else
|
||||
{
|
||||
var itemDirection = Entity.Direction.Rotate(Item.EquippableItem.Rotation);
|
||||
return float3(itemDirection.x, 0, itemDirection.y);
|
||||
}
|
||||
}
|
||||
|
||||
return float3(Entity.Direction.x, 0, Entity.Direction.y);
|
||||
}
|
||||
}
|
||||
|
||||
protected Behavior(BehaviorData data, EquippedItem item)
|
||||
{
|
||||
Data = data;
|
||||
Item = item;
|
||||
ItemManager = Item.ItemManager;
|
||||
}
|
||||
|
||||
protected Behavior(BehaviorData data, ConsumableItemEffect consumable)
|
||||
{
|
||||
Data = data;
|
||||
Consumable = consumable;
|
||||
ItemManager = consumable.Entity.ItemManager;
|
||||
}
|
||||
|
||||
public float Evaluate(PerformanceStat stat) => Item?.Evaluate(stat) ?? Consumable.Evaluate(stat);
|
||||
protected void AddHeat(float heat) => Item?.AddHeat(heat); // TODO: Heat for Consumables
|
||||
|
||||
protected void CauseDamage(float damage)
|
||||
{
|
||||
if (Item != null)
|
||||
{
|
||||
Item.EquippableItem.Durability -= damage;
|
||||
Entity.ItemDamage.OnNext((Item, damage));
|
||||
}
|
||||
else
|
||||
{
|
||||
Consumable.Entity.Hull.Durability -= damage;
|
||||
Consumable.Entity.HullDamage.OnNext(damage);
|
||||
}
|
||||
}
|
||||
|
||||
protected void CauseWearDamage(float multiplier)
|
||||
{
|
||||
if (Item != null)
|
||||
{
|
||||
CauseDamage(Item.Wear * multiplier);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool Execute(float dt)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public interface IActivatedBehavior : IBehavior
|
||||
public interface IActivatedBehavior
|
||||
{
|
||||
void Activate();
|
||||
void Deactivate();
|
||||
}
|
||||
|
||||
public interface IAnalogBehavior : IBehavior
|
||||
public interface IAnalogBehavior
|
||||
{
|
||||
float Axis { get; set; }
|
||||
}
|
||||
|
||||
public interface IDisposableBehavior
|
||||
{
|
||||
void Dispose();
|
||||
}
|
||||
|
||||
public interface IEventBehavior
|
||||
{
|
||||
void ResetEvents();
|
||||
|
|
@ -128,12 +194,11 @@ public abstract class BehaviorData
|
|||
[Inspectable, JsonProperty("group"), Key(0)]
|
||||
public int Group;
|
||||
|
||||
public abstract IBehavior CreateInstance(EquippedItem item);
|
||||
public abstract Behavior CreateInstance(EquippedItem item);
|
||||
public abstract Behavior CreateInstance(ConsumableItemEffect consumable);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var className = base.ToString();
|
||||
var dataIndex = className.IndexOf("data", StringComparison.InvariantCultureIgnoreCase);
|
||||
return dataIndex>0 ? className.Substring(0,dataIndex).SplitCamelCase() : className;
|
||||
return base.ToString().FormatTypeName();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue