예제 #1
0
 public DelayedAction(PowerNetManager.DelayedActionType type, CompPower compPower)
 {
     this.type      = type;
     this.compPower = compPower;
     this.position  = compPower.parent.Position;
     this.rotation  = compPower.parent.Rotation;
 }
예제 #2
0
        public void UpdatePowerNetsAndConnections_First()
        {
            int count = this.delayedActions.Count;

            for (int i = 0; i < count; i++)
            {
                PowerNetManager.DelayedAction     delayedAction = this.delayedActions[i];
                PowerNetManager.DelayedActionType type          = this.delayedActions[i].type;
                if (type != PowerNetManager.DelayedActionType.RegisterTransmitter)
                {
                    if (type == PowerNetManager.DelayedActionType.DeregisterTransmitter)
                    {
                        this.TryDestroyNetAt(delayedAction.position);
                        PowerConnectionMaker.DisconnectAllFromTransmitterAndSetWantConnect(delayedAction.compPower, this.map);
                        delayedAction.compPower.ResetPowerVars();
                    }
                }
                else if (delayedAction.position == delayedAction.compPower.parent.Position)
                {
                    ThingWithComps parent = delayedAction.compPower.parent;
                    if (this.map.powerNetGrid.TransmittedPowerNetAt(parent.Position) != null)
                    {
                        Log.Warning(string.Concat(new object[]
                        {
                            "Tried to register trasmitter ",
                            parent,
                            " at ",
                            parent.Position,
                            ", but there is already a power net here. There can't be two transmitters on the same cell."
                        }), false);
                    }
                    delayedAction.compPower.SetUpPowerVars();
                    foreach (IntVec3 cell in GenAdj.CellsAdjacentCardinal(parent))
                    {
                        this.TryDestroyNetAt(cell);
                    }
                }
            }
            for (int j = 0; j < count; j++)
            {
                PowerNetManager.DelayedAction delayedAction2 = this.delayedActions[j];
                if ((delayedAction2.type == PowerNetManager.DelayedActionType.RegisterTransmitter && delayedAction2.position == delayedAction2.compPower.parent.Position) || delayedAction2.type == PowerNetManager.DelayedActionType.DeregisterTransmitter)
                {
                    this.TryCreateNetAt(delayedAction2.position);
                    foreach (IntVec3 cell2 in GenAdj.CellsAdjacentCardinal(delayedAction2.position, delayedAction2.rotation, delayedAction2.compPower.parent.def.size))
                    {
                        this.TryCreateNetAt(cell2);
                    }
                }
            }
            for (int k = 0; k < count; k++)
            {
                PowerNetManager.DelayedAction     delayedAction3 = this.delayedActions[k];
                PowerNetManager.DelayedActionType type2          = this.delayedActions[k].type;
                if (type2 != PowerNetManager.DelayedActionType.RegisterConnector)
                {
                    if (type2 == PowerNetManager.DelayedActionType.DeregisterConnector)
                    {
                        PowerConnectionMaker.DisconnectFromPowerNet(delayedAction3.compPower);
                        delayedAction3.compPower.ResetPowerVars();
                    }
                }
                else if (delayedAction3.position == delayedAction3.compPower.parent.Position)
                {
                    delayedAction3.compPower.SetUpPowerVars();
                    PowerConnectionMaker.TryConnectToAnyPowerNet(delayedAction3.compPower, null);
                }
            }
            this.delayedActions.RemoveRange(0, count);
            if (DebugViewSettings.drawPower)
            {
                this.DrawDebugPowerNets();
            }
        }