示例#1
0
        public static HullRuleSet deserialize(VRage.ByteStream stream)
        {
            HullRuleSet result = new HullRuleSet();
            result.DisplayName = stream.getString();
            result.MaxPerFaction = stream.getUShort();
            result.MaxPerSoloPlayer = stream.getUShort();
            result.CaptureMultiplier = stream.getUShort();
            result.MaxBlocks = (int)stream.getLong();
            result.ShouldBeStation = stream.getBoolean();

            ushort blockTypeLimitsCount = stream.getUShort();
            result.BlockTypeLimits = new int[blockTypeLimitsCount];
            for (ushort i = 0; i < blockTypeLimitsCount; ++i) {
                result.BlockTypeLimits[i] = stream.getUShort();
            }

            return result;
        }
示例#2
0
        public static HullRuleSet deserialize(VRage.ByteStream stream)
        {
            HullRuleSet result = new HullRuleSet();

            result.DisplayName       = stream.getString();
            result.MaxPerFaction     = stream.getUShort();
            result.MaxPerSoloPlayer  = stream.getUShort();
            result.CaptureMultiplier = stream.getUShort();
            result.MaxBlocks         = (int)stream.getLong();
            result.ShouldBeStation   = stream.getBoolean();

            ushort blockTypeLimitsCount = stream.getUShort();

            result.BlockTypeLimits = new int[blockTypeLimitsCount];
            for (ushort i = 0; i < blockTypeLimitsCount; ++i)
            {
                result.BlockTypeLimits[i] = stream.getUShort();
            }

            return(result);
        }
示例#3
0
        public override void Init(MyObjectBuilder_EntityBase objectBuilder)
        {
            base.Init(objectBuilder);
            m_Grid = Container.Entity as IMyCubeGrid;

            m_Logger = new Logger(m_Grid.EntityId.ToString(), "GridEnforcer");
            log("Loaded into new grid", "Init");

            // If this is not the server we don't need this class.
            // When we modify the grid on the server the changes should be
            // sent to all clients
            try {
                m_IsServer = Utility.isServer();
                log("Is server: " + m_IsServer, "Init");
                if (!m_IsServer) {
                    // No cleverness allowed :[
                    log("Disabled.  Not server.", "Init");
                    m_Logger = null;
                    m_Grid = null;
                    return;
                }
            } catch (NullReferenceException e) {
                log("Exception.  Multiplayer is not initialized.  Assuming server for time being: " + e,
                    "Init");
                // If we get an exception because Multiplayer was null (WHY KEEN???)
                // assume we are the server for a little while and check again later
                m_IsServer = true;
                m_CheckServerLater = true;
            }

            // We need to only turn on our rule checking after startup. Otherwise, if
            // a beacon is destroyed and then the server restarts, all but the first
            // 25 blocks will be deleted on startup.
            m_Grid.NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME;

            m_BlockCount = 0;
            m_BlockTypeCounts = new int[s_Settings.BlockTypes.Length];
            m_Owner = new GridOwner(this);
            m_Classifiers = new Dictionary<long, HullClassifier>();
            m_Projectors = new Dictionary<long, InGame.IMyProjector>();
            m_ReservedClass = DEFAULT_CLASS;
            m_ReservedRules = s_Settings.HullRules[(int)DEFAULT_CLASS];
            m_EffectiveClass = DEFAULT_CLASS;
            m_EffectiveRules = s_Settings.HullRules[(int)DEFAULT_CLASS];
            reserveEffectiveClassFromOwner();

            m_Grid.OnBlockAdded += blockAdded;
            m_Grid.OnBlockRemoved += blockRemoved;
            m_Grid.OnBlockOwnershipChanged += blockOwnerChanged;
            m_GridSubscribed = true;
        }
示例#4
0
 private void setReservedTo(HullClass.CLASS newClass)
 {
     if (m_ReservedClass == newClass) {
         log("No change, ReservedClass remains " + m_ReservedClass, "setReservedTo");
     }
     else {
         log("Changing ReservedClass from " + m_ReservedClass + " to " + newClass,
             "setReservedTo");
         m_ReservedClass = newClass;
         m_ReservedRules = s_Settings.HullRules[(int)newClass];
     }
 }
示例#5
0
 private void setEffectiveTo(HullClass.CLASS newClass)
 {
     if (m_EffectiveClass == newClass) {
         log("No changed, EffectiveClass remains " + m_EffectiveClass, "setEffectiveTo");
     }
     else {
         log("Changing EffectiveClass from " + m_EffectiveClass + " to " + newClass,
             "setEffectiveTo");
         m_EffectiveClass = newClass;
         m_EffectiveRules = s_Settings.HullRules[(int)newClass];
         reserveEffectiveClassFromOwner();
         m_CheckCleanupNextUpdate = true;
     }
 }
示例#6
0
        private HullRuleSet[] defaultHullRules()
        {
            // Hull Rules indexed by Class
            int totalHullClasses = Enum.GetNames(typeof(HullClass.CLASS)).Length;
            HullRuleSet[] results = new HullRuleSet[totalHullClasses];

            results[(int)HullClass.CLASS.UNCLASSIFIED] = new HullRuleSet() {
                DisplayName = "Unclassified",
                MaxPerFaction = 0,
                MaxPerSoloPlayer = 0,
                CaptureMultiplier = 0,
                MaxBlocks = 25,
                BlockTypeLimits = new int[7] {
                    //-1,  // Conveyors
                    //0,   // Gravity
                    0,     // Industrial
                    //0,   // Logic
                    0,     // Projector
                    0,     // Spotlight
                    0,     // Solar
                    0,     // Static W
                    //-1,  // Thrusters
                    0,     // Tools
                    0      // Turrets
                }
            };
            results[(int)HullClass.CLASS.UNLICENSED] = new HullRuleSet() {
                DisplayName = "Unlicensed",
                MaxPerFaction = 3,
                MaxPerSoloPlayer = 3,
                CaptureMultiplier = 1,
                MaxBlocks = 125,
                BlockTypeLimits = new int[7] {
                    //10,  // Conveyors
                    //1,   // Gravity
                    3,     // Industrial
                    //0,   // Logic
                    0,     // Projector
                    1,     // Spotlight
                    0,     // Solar
                    2,     // Static W
                    //14,  // Thrusters
                    1,     // Tools
                    1      // Turrets
                }
            };
            results[(int)HullClass.CLASS.WORKER] = new HullRuleSet() {
                DisplayName = "Worker",
                MaxPerFaction = 8,
                MaxPerSoloPlayer = 0,
                CaptureMultiplier = 1,
                MaxBlocks = 350,
                BlockTypeLimits = new int[7] {
                    //30,  // Conveyors
                    //0,   // Gravity
                    0,     // Industrial
                    //2,   // Logic
                    1,     // Projector
                    1,     // Spotlight
                    0,     // Solar
                    0,     // Static W
                    //24,  // Thrusters
                    3,     // Tools
                    0      // Turrets
                }
            };
            results[(int)HullClass.CLASS.FOUNDRY] = new HullRuleSet() {
                DisplayName = "Foundry",
                MaxPerFaction = 1,
                MaxPerSoloPlayer = 0,
                CaptureMultiplier = 3,
                MaxBlocks = 1000,
                BlockTypeLimits = new int[7] {
                    //60,  // Conveyors
                    //1,   // Gravity
                    6,     // Industrial
                    //4,   // Logic
                    0,     // Projector
                    1,     // Spotlight
                    0,     // Solar
                    0,     // Static W
                    //12,  // Thrusters
                    0,     // Tools
                    2      // Turrets
                }
            };
            results[(int)HullClass.CLASS.SCOUT] = new HullRuleSet() {
                DisplayName = "Scout",
                MaxPerFaction = 5,
                MaxPerSoloPlayer = 0,
                CaptureMultiplier = 1,
                MaxBlocks = 225,
                BlockTypeLimits = new int[7] {
                    //20,  // Conveyors
                    //0,   // Gravity
                    0,     // Industrial
                    //2,   // Logic
                    0,     // Projector
                    0,     // Spotlight
                    0,     // Solar
                    2,     // Static W
                    //24,  // Thrusters
                    0,     // Tools
                    0      // Turrets
                }
            };
            results[(int)HullClass.CLASS.FIGHTER] = new HullRuleSet() {
                DisplayName = "Fighter",
                MaxPerFaction = 16,
                MaxPerSoloPlayer = 0,
                CaptureMultiplier = 2,
                MaxBlocks = 550,
                BlockTypeLimits = new int[7] {
                    //40,  // Conveyors
                    //0,   // Gravity
                    0,     // Industrial
                    //0,   // Logic
                    0,     // Projector
                    0,     // Spotlight
                    0,     // Solar
                    4,     // Static W
                    //24,  // Thrusters
                    0,     // Tools
                    0      // Turrets
                }
            };
            results[(int)HullClass.CLASS.GUNSHIP] = new HullRuleSet() {
                DisplayName = "Gunship",
                MaxPerFaction = 3,
                MaxPerSoloPlayer = 0,
                CaptureMultiplier = 3,
                MaxBlocks = 1300,
                BlockTypeLimits = new int[7] {
                    //60,  // Conveyors
                    //0,   // Gravity
                    0,     // Industrial
                    //1,   // Logic
                    0,     // Projector
                    1,     // Spotlight
                    0,     // Solar
                    8,     // Static W
                    //30,  // Thrusters
                    0,     // Tools
                    1      // Turrets
                }
            };
            results[(int)HullClass.CLASS.CORVETTE] = new HullRuleSet() {
                DisplayName = "Corvette",
                MaxPerFaction = 6,
                MaxPerSoloPlayer = 0,
                CaptureMultiplier = 4,
                MaxBlocks = 200,
                BlockTypeLimits = new int[7] {
                    //10,  // Conveyors
                    //0,   // Gravity
                    0,     // Industrial
                    //0,   // Logic
                    0,     // Projector
                    0,     // Spotlight
                    0,     // Solar
                    2,     // Static W
                    //24,  // Thrusters
                    0,     // Tools
                    2      // Turrets
                }
            };
            results[(int)HullClass.CLASS.FRIGATE] = new HullRuleSet() {
                DisplayName = "Frigate",
                MaxPerFaction = 4,
                MaxPerSoloPlayer = 0,
                CaptureMultiplier = 6,
                MaxBlocks = 600,
                BlockTypeLimits = new int[7] {
                    //40,  // Conveyors
                    //1,   // Gravity
                    0,     // Industrial
                    //2,   // Logic
                    0,     // Projector
                    0,     // Spotlight
                    0,     // Solar
                    4,     // Static W
                    //30,  // Thrusters
                    0,     // Tools
                    3      // Turrets
                }
            };

            results[(int)HullClass.CLASS.DESTROYER] = new HullRuleSet() {
                DisplayName = "Destroyer",
                MaxPerFaction = 2,
                MaxPerSoloPlayer = 0,
                CaptureMultiplier = 10,
                MaxBlocks = 1800,
                BlockTypeLimits = new int[7] {
                    //60,  // Conveyors
                    //2,   // Gravity
                    0,     // Industrial
                    //4,   // Logic
                    0,     // Projector
                    0,     // Spotlight
                    0,     // Solar
                    6,     // Static W
                    //36,  // Thrusters
                    0,     // Tools
                    4      // Turrets
                }

            };
            results[(int)HullClass.CLASS.CRUISER] = new HullRuleSet() {
                DisplayName = "Cruiser",
                MaxPerFaction = 1,
                MaxPerSoloPlayer = 0,
                CaptureMultiplier = 15,
                MaxBlocks = 2700,
                BlockTypeLimits = new int[7] {
                    //80,  // Conveyors
                    //4,   // Gravity
                    0,     // Industrial
                    //6,   // Logic
                    0,     // Projector
                    1,     // Spotlight
                    0,     // Solar
                    8,     // Static W
                    //42,  // Thrusters
                    0,     // Tools
                    6      // Turrets
                }
            };
            results[(int)HullClass.CLASS.HEAVYCRUISER] = new HullRuleSet() {
                DisplayName = "Heavy Cruiser",
                MaxPerFaction = 0,
                MaxPerSoloPlayer = 0,
                CaptureMultiplier = 20,
                MaxBlocks = 4050,
                BlockTypeLimits = new int[7] {
                    //80,  // Conveyors
                    //4,   // Gravity
                    0,     // Industrial
                    //6,   // Logic
                    0,     // Projector
                    1,     // Spotlight
                    0,     // Solar
                    10,     // Static W
                    //42,  // Thrusters
                    0,     // Tools
                    8      // Turrets
                }
            };
            results[(int)HullClass.CLASS.BATTLESHIP] = new HullRuleSet() {
                DisplayName = "Battleship",
                MaxPerFaction = 0,
                MaxPerSoloPlayer = 0,
                CaptureMultiplier = 30,
                MaxBlocks = 6075,
                BlockTypeLimits = new int[7] {
                    //80,  // Conveyors
                    //4,   // Gravity
                    0,     // Industrial
                    //6,   // Logic
                    0,     // Projector
                    1,     // Spotlight
                    0,     // Solar
                    12,     // Static W
                    //42,  // Thrusters
                    0,     // Tools
                    10      // Turrets
                }
            };
            results[(int)HullClass.CLASS.OUTPOST] = new HullRuleSet() {
                DisplayName = "Outpost",
                MaxPerFaction = 3,
                MaxPerSoloPlayer = 0,
                CaptureMultiplier = 4,
                MaxBlocks = 600,
                BlockTypeLimits = new int[7] {
                    //40,  // Conveyors
                    //1,   // Gravity
                    5,     // Industrial
                    //2,   // Logic
                    0,     // Projector
                    0,     // Spotlight
                    6,     // Solar
                    0,     // Static W
                    //2,  // Thrusters
                    0,     // Tools
                    2      // Turrets
                },
                ShouldBeStation = true
            };
            results[(int)HullClass.CLASS.INSTALLATION] = new HullRuleSet() {
                DisplayName = "Installation",
                MaxPerFaction = 2,
                MaxPerSoloPlayer = 0,
                CaptureMultiplier = 8,
                MaxBlocks = 1800,
                BlockTypeLimits = new int[7] {
                    //60,  // Conveyors
                    //2,   // Gravity
                    7,     // Industrial
                    //4,   // Logic
                    0,     // Projector
                    0,     // Spotlight
                    12,     // Solar
                    0,     // Static W
                    //2,  // Thrusters
                    2,     // Tools
                    4      // Turrets
                },
                ShouldBeStation = true
            };
            results[(int)HullClass.CLASS.FORTRESS] = new HullRuleSet() {
                DisplayName = "Fortress",
                MaxPerFaction = 1,
                MaxPerSoloPlayer = 0,
                CaptureMultiplier = 12,
                MaxBlocks = 2700,
                BlockTypeLimits = new int[7] {
                    //80,  // Conveyors
                    //3,   // Gravity
                    10,     // Industrial
                    //6,   // Logic
                    0,     // Projector
                    1,     // Spotlight
                    18,     // Solar
                    0,     // Static W
                    //2,  // Thrusters
                    4,     // Tools
                    6      // Turrets
                },
                ShouldBeStation = true
            };

            return results;
        }