public void breaklink(int myinputIndx) { StrategyBaseBlock otherblock = this.inputLnks[myinputIndx]; int dex = otherblock.outputLnks.FindIndex(item => item == this); otherblock.outputLnks[dex] = null; this.inputLnks[myinputIndx] = null; }
/// <summary> /// Resets all in /// </summary> public void zeroize() { if (inputLnks != null) { for (int i = 0; i < inputLnks.Length; i++) { StrategyBaseBlock lnk = inputLnks[i]; if (lnk != null) { lnk.zeroize(); lnk = null; output = null; inputs[i] = null; } } } }
public StragegyObject_Default() : base() { StrategyWayPoint wpnt = new StrategyWayPoint(); StrategyClosest closest1 = new StrategyClosest();//(null, null); StrategyThisObj thisobj = new StrategyThisObj(); StrategyThisEnemys thisobjEnemys = new StrategyThisEnemys(); StrategyLocdata enloc = new StrategyLocdata(); StrategyVeldata envel = new StrategyVeldata(); Strategyinput_Types type = new Strategyinput_Types(); wpnt.inputLnks[0] = enloc; wpnt.inputLnks[1] = envel; closest1.inputLnks[0] = thisobj; closest1.inputLnks[1] = thisobjEnemys; closest1.inputLnks[2] = type; closest1.outputLnks.Add(enloc); closest1.outputLnks.Add(envel); enloc.inputLnks[0] = closest1; enloc.outputLnks.Add(wpnt); envel.inputLnks[0] = closest1; envel.outputLnks.Add(wpnt); waypointObj = wpnt; blocks = new StrategyBaseBlock[3] { closest1, enloc, envel }; targetObjs = new StrategyBaseBlock[1] { closest1 }; weaponslists = new List <Dictionary <int, MountedComponentTemplate> >(); Dictionary <int, MountedComponentTemplate> wpnsinFC0 = new Dictionary <int, MountedComponentTemplate>(); for (int i = 0; i < 10; i++) { wpnsinFC0.Add(i, null); } weaponslists.Add(wpnsinFC0); }
public virtual void calc(CombatObject comObj) { for (int i = 0; i < inputLnks.Length; i++) { StrategyBaseBlock lnk = inputLnks[i]; if (lnk == null) { inputs[i] = DefaultValues[i]; } else { if (lnk.output == null) { lnk.calc(comObj); } inputs[i] = lnk.output; } } }
/// <summary> /// links thisblock to another blocks output. /// </summary> /// <param name="myinputIndx">the input link</param> /// <param name="otherblock">the other block</param> public void makelink(int myinputIndx, StrategyBaseBlock otherblock) { if (inputtypes == null) { throw new InvalidOperationException("Input types for strategy block not initialized."); } if (inputtypes.Length <= myinputIndx) { throw new ArgumentOutOfRangeException("This strategy block does not have that many inputs."); } if (!inputtypes[myinputIndx].Type.IsAssignableFrom(otherblock.outputType.Type)) { throw new ArgumentException("Cannot link an output of type " + otherblock.outputType + " to an input of type " + inputtypes[myinputIndx] + "."); } this.inputLnks[myinputIndx] = otherblock; if (!otherblock.outputLnks.Contains(this)) { otherblock.outputLnks.Add(this); } }
public StrategyObject(string name, StrategyBaseBlock waypointstratObj, StrategyBaseBlock[] targetstratObjs) { this.waypointObj = waypointstratObj; this.targetObjs = targetstratObjs; this.Name = name; }