New Mining Controller Behavior and Mining Tool Behavior, tweaked a bunch of asteroid related stuff
This commit is contained in:
hyperion51 2020-05-28 04:50:40 +01:00
commit 399b933a38
22 changed files with 609 additions and 58 deletions

View file

@ -45,6 +45,15 @@ public abstract class Entity : DatabaseEntry, IMessagePackSerializationCallbackR
[IgnoreMember] public float OccupiedCapacity { get; private set; }
[IgnoreMember] public float SpecificHeat { get; private set; }
[IgnoreMember] public float Visibility => VisibilitySources.Values.Sum();
public float Capacity
{
get
{
var hull = Context.Cache.Get<Gear>(Hull);
var hullData = Context.Cache.Get<HullData>(hull.Data);
return Context.Evaluate(hullData.Capacity, hull, this);
}
}
[IgnoreMember] public string EntryName
{
@ -168,6 +177,21 @@ public abstract class Entity : DatabaseEntry, IMessagePackSerializationCallbackR
return -1;
}
public int GetSwitch<T>() where T : class, IBehavior
{
var s = Behaviors
.FirstOrDefault(x => x.Value.Any(g => g is Switch) && x.Value.Any(g => g is T))
.Value.First(g => g is Switch) as Switch;
return Switches.FirstOrDefault(kvp => kvp.Value == s).Key;
}
public Switch GetSwitch(IBehavior behavior)
{
return Behaviors
.FirstOrDefault(x => x.Value.Any(g => g == behavior))
.Value.First(g => g is Switch) as Switch;
}
public void AddHeat(float heat)
{
if (Parent != Guid.Empty)