예제 #1
0
        public void RegisterTransmitter(CompPowerZTransmitter comp)
        {
            Log.Message("Registering: " + comp);
            var lowerMap = ZUtils.ZTracker.GetLowerLevel(comp.parent.Tile, comp.parent.Map);
            var upperMap = ZUtils.ZTracker.GetUpperLevel(comp.parent.Tile, comp.parent.Map);

            foreach (var powerNet in powerNets)
            {
                if (!powerNet.Value.ConnectedTransmitters.Contains(comp))
                {
                    if (powerNet.Value.ConnectedTransmitters.FirstOrDefault()?.PowerNet == comp.PowerNet)
                    {
                        AddTransmitter(powerNet.Value, comp);
                        return;
                    }
                    if (lowerMap != null)
                    {
                        var lowerComps = powerNet.Value.ConnectedTransmitters.Where(x => x.parent.Map == lowerMap);
                        foreach (var lowerComp in lowerComps)
                        {
                            if (lowerComp.parent.Position.DistanceTo(comp.parent.Position) < 3)
                            {
                                AddTransmitter(powerNet.Value, comp);
                                return;
                            }
                        }
                    }
                    if (upperMap != null)
                    {
                        var upperComps = powerNet.Value.ConnectedTransmitters.Where(x => x.parent.Map == upperMap);
                        foreach (var upperComp in upperComps)
                        {
                            if (upperComp.parent.Position.DistanceTo(comp.parent.Position) < 3)
                            {
                                AddTransmitter(powerNet.Value, comp);
                                return;
                            }
                        }
                    }
                }
                else
                {
                    return;
                }
            }
            var connectedPowerNet = new ConnectedPowerNet(comp);

            AddTransmitter(connectedPowerNet, comp);
            powerNets.Add(powerNets.Count + 1, connectedPowerNet);
        }
예제 #2
0
 public void AddTransmitter(ConnectedPowerNet connectedPowerNet, CompPowerZTransmitter compPowerZTransmitter)
 {
     connectedPowerNet.AddTransmitter(compPowerZTransmitter);
     connectedPowerNetsDict[compPowerZTransmitter.PowerNet] = connectedPowerNet;
 }