Exemplo n.º 1
0
        /*
         * [DebuggerHidden]
         * public override IEnumerable<Gizmo> CompGetGizmosExtra() {
         *  CompShield.< CompGetGizmosExtra > c__IteratorB2 < CompGetGizmosExtra > c__IteratorB = new CompShield.< CompGetGizmosExtra > c__IteratorB2();
         *
         *  < CompGetGizmosExtra > c__IteratorB.<> f__this = this;
         *  CompShield.< CompGetGizmosExtra > c__IteratorB2 expr_0E = < CompGetGizmosExtra > c__IteratorB;
         *  expr_0E.$PC = -2;
         *  return expr_0E;
         * }
         */

        private void TryManualReconnect()
        {
            if (CompShield.lastManualReconnector != this)
            {
                CompShield.recentlyConnectedNets.Clear();
                CompShield.lastManualReconnector = this;
            }
            if (this.ShieldNet != null)
            {
                CompShield.recentlyConnectedNets.Add(this.ShieldNet);
            }
            CompShield compPower = ShieldConnectionMaker.BestTransmitterForConnector(this.parent.Position, this.parent.Map, CompShield.recentlyConnectedNets);

            if (compShield == null)
            {
                CompShield.recentlyConnectedNets.Clear();
                compPower = ShieldConnectionMaker.BestTransmitterForConnector(this.parent.Position, this.parent.Map, null);
            }
            if (compPower != null)
            {
                ShieldConnectionMaker.DisconnectFromPowerNet(this);
                this.ConnectToTransmitter(compPower, false);
                for (int i = 0; i < 5; i++)
                {
                    MoteMaker.ThrowMetaPuff(compPower.parent.Position.ToVector3Shifted(), compPower.parent.Map);
                }
                this.parent.Map.mapDrawer.MapMeshDirty(this.parent.Position, MapMeshFlag.PowerGrid);
                this.parent.Map.mapDrawer.MapMeshDirty(this.parent.Position, MapMeshFlag.Things);
            }
        }
Exemplo n.º 2
0
 private void TryCreateNetAt(IntVec3 cell)
 {
     if (!cell.InBounds(this.map))
     {
         return;
     }
     if (this.map.powerNetGrid.TransmittedPowerNetAt(cell) == null)
     {
         Building transmitter = cell.GetTransmitter(this.map);
         if (transmitter != null && transmitter.TransmitsPowerNow)
         {
             ShieldNet powerNet = ShieldNetMaker.NewPowerNetStartingFrom(transmitter);
             this.RegisterShieldNet(powerNet);
             for (int i = 0; i < powerNet.transmitters.Count; i++)
             {
                 ShieldConnectionMaker.ConnectAllConnectorsToTransmitter(powerNet.transmitters[i]);
             }
         }
     }
 }
Exemplo n.º 3
0
        public void UpdatePowerNetsAndConnections_First()
        {
            int count = this.delayedActions.Count;

            for (int i = 0; i < count; i++)
            {
                ShieldNetManager.DelayedAction     delayedAction = this.delayedActions[i];
                ShieldNetManager.DelayedActionType type          = this.delayedActions[i].type;
                if (type != ShieldNetManager.DelayedActionType.RegisterTransmitter)
                {
                    if (type == ShieldNetManager.DelayedActionType.DeregisterTransmitter)
                    {
                        this.TryDestroyNetAt(delayedAction.compShield.parent.Position);
                        ShieldConnectionMaker.DisconnectAllFromTransmitterAndSetWantConnect(delayedAction.compShield, this.map);
                        delayedAction.compShield.ResetPowerVars();
                    }
                }
                else
                {
                    ThingWithComps parent = delayedAction.compShield.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."
                        }));
                    }
                    delayedAction.compShield.SetUpPowerVars();
                    foreach (IntVec3 current in GenAdj.CellsAdjacentCardinal(parent))
                    {
                        this.TryDestroyNetAt(current);
                    }
                }
            }
            for (int j = 0; j < count; j++)
            {
                ShieldNetManager.DelayedAction delayedAction2 = this.delayedActions[j];
                if (delayedAction2.type == ShieldNetManager.DelayedActionType.RegisterTransmitter || delayedAction2.type == ShieldNetManager.DelayedActionType.DeregisterTransmitter)
                {
                    this.TryCreateNetAt(delayedAction2.compShield.parent.Position);
                    foreach (IntVec3 current2 in GenAdj.CellsAdjacentCardinal(delayedAction2.compShield.parent))
                    {
                        this.TryCreateNetAt(current2);
                    }
                }
            }
            for (int k = 0; k < count; k++)
            {
                ShieldNetManager.DelayedAction     delayedAction3 = this.delayedActions[k];
                ShieldNetManager.DelayedActionType type           = this.delayedActions[k].type;
                if (type != ShieldNetManager.DelayedActionType.RegisterConnector)
                {
                    if (type == ShieldNetManager.DelayedActionType.DeregisterConnector)
                    {
                        ShieldConnectionMaker.DisconnectFromPowerNet(delayedAction3.compShield);
                        delayedAction3.compShield.ResetPowerVars();
                    }
                }
                else
                {
                    delayedAction3.compShield.SetUpPowerVars();
                    ShieldConnectionMaker.TryConnectToAnyPowerNet(delayedAction3.compShield, null);
                }
            }
            this.delayedActions.RemoveRange(0, count);
            if (DebugViewSettings.drawPower)
            {
                this.DrawDebugPowerNets();
            }
        }