public void Add(IThruster thruster) { var orientation = ((IBlock)thruster).blockBaseClass.orientation; var tempThrustVector = thrustVectors[orientation]; tempThrustVector.AddToGroup(thruster); thrustVectors[orientation] = tempThrustVector; }
public void Remove(IThruster thruster) { var orientation = ((IBlock)thruster).blockBaseClass.orientation; var tempThrustVector = thrustVectors[orientation]; tempThrustVector.RemoveFromGroup(thruster); thrustVectors[orientation] = tempThrustVector; }
private ThrusterAxis SelectAxis(IThruster thruster, out bool positiveAxisComponent) { var block = thruster.Component.block; var direction = block.BlueprintBlock.Direction; positiveAxisComponent = direction <= 1; return(direction % 2 == 0 ? xAxis : yAxis); }
private ThrusterGroup SelectGroup(IThruster thruster) { var rotation = GetDirection(thruster); try { return(thrusterDict[rotation]); } catch (KeyNotFoundException) { Debug.LogWarning( $"thruster {thruster} with rotation {rotation} cannot find a corresponding thruster group"); return(null); } }
// Start is called before the first frame update void Start() { if (mThruster == null) { mThruster = GetComponent <IThruster>(); } if (mTurner == null) { mTurner = GetComponent <ITurner>(); } if (mShooter == null) { mShooter = GetComponent <IShooter>(); } }
public void RemoveFromGroup(IThruster thruster) { thrusterMembers.Remove(thruster); thrust -= thruster.thrust; _consumption -= thruster.powerConsumption; }
public void AddToGroup(IThruster thruster) { thrusterMembers.Add(thruster); thrust += thruster.thrust; _consumption += thruster.powerConsumption; }
public void Unregister(IThruster thruster, bool positiveComponent) { SelectGroup(positiveComponent).Remove(thruster); }
public void Register(IThruster thruster, bool positiveComponent) { SelectGroup(positiveComponent).Add(thruster); }
public void Unregister(IThruster thruster) { SelectAxis(thruster, out var component).Unregister(thruster, component); }
public void SetThruster(IThruster t) { mThruster = t; }
private void Start() { _thruster = Thruster.GetComponent <IThruster>(); }
private int GetDirection(IThruster thruster) { return(thruster.Component.block.anchoredBlueprintBlock.blueprintBlock.Direction); }
public void Unregister(IThruster thruster) { SelectGroup(thruster)?.Remove(thruster); }
public void Register(IThruster thruster) { SelectGroup(thruster)?.Add(thruster); }