コード例 #1
0
 protected GameObjectRegistry( )
 {
     m_registry             = new Dictionary <Guid, HashSet <GameObjectTypeEntry> >( );
     m_typeMap              = new Dictionary <Type, Type>( );
     m_generalCategory      = new GameObjectCategory( );
     m_generalCategory.id   = 0;
     m_generalCategory.name = "General";
 }
コード例 #2
0
		protected GameObjectRegistry()
		{
			m_registry = new Dictionary<Guid, HashSet<GameObjectTypeEntry>>();
			m_typeMap = new Dictionary<Type, Type>();
			m_generalCategory = new GameObjectCategory();
			m_generalCategory.id = 0;
			m_generalCategory.name = "General";
		}
コード例 #3
0
        public void Register(Type gameType, Type apiType, GameObjectCategory category)
        {
            if (apiType == null || gameType == null)
            {
                return;
            }
            if (!typeof(MyObjectBuilder_Base).IsAssignableFrom(gameType))
            {
                return;
            }
            if (!typeof(BaseObject).IsAssignableFrom(apiType))
            {
                return;
            }
            if (m_typeMap.ContainsKey(gameType))
            {
                return;
            }
            if (m_typeMap.ContainsValue(apiType))
            {
                return;
            }
            if (!ValidateRegistration(gameType, apiType))
            {
                return;
            }

            GuidAttribute guid      = (GuidAttribute)Assembly.GetCallingAssembly( ).GetCustomAttributes(typeof(GuidAttribute), true)[0];
            Guid          guidValue = new Guid(guid.Value);

            GameObjectTypeEntry entry = new GameObjectTypeEntry( );

            entry.source   = guidValue;
            entry.gameType = gameType;
            entry.apiType  = apiType;
            entry.enabled  = true;
            entry.category = category;

            m_typeMap.Add(gameType, apiType);

            if (m_registry.ContainsKey(guidValue))
            {
                HashSet <GameObjectTypeEntry> hashSet = m_registry[guidValue];
                hashSet.Add(entry);
            }
            else
            {
                HashSet <GameObjectTypeEntry> hashSet = new HashSet <GameObjectTypeEntry>( );
                hashSet.Add(entry);
                m_registry.Add(guidValue, hashSet);
            }
        }
コード例 #4
0
        public void Register(Type gameType, Type apiType, GameObjectCategory category)
        {
            if (CategoryMap.ContainsKey(category))
            {
                //Update the existing category list with the new game type
                List <Type> types = CategoryMap[category];
                if (!types.Contains(gameType))
                {
                    types.Add(gameType);
                }
            }
            else
            {
                //Create a new entry in the category map with the new game type
                List <Type> types = new List <Type>();
                types.Add(gameType);
                m_categoryMap.Add(category, types);
            }

            //Register the game type
            Register(gameType, apiType);
        }
コード例 #5
0
        public void Register(Type gameType, Type apiType, GameObjectCategory category)
        {
            if (CategoryMap.ContainsKey(category))
            {
                //Update the existing category list with the new game type
                List<Type> types = CategoryMap[category];
                if (!types.Contains(gameType))
                {
                    types.Add(gameType);
                }
            }
            else
            {
                //Create a new entry in the category map with the new game type
                List<Type> types = new List<Type>();
                types.Add(gameType);
                m_categoryMap.Add(category, types);
            }

            //Register the game type
            Register(gameType, apiType);
        }
コード例 #6
0
		protected BlockRegistry()
		{
			GameObjectCategory structural = new GameObjectCategory();
			structural.id = 1;
			structural.name = "Structural";
			GameObjectCategory containers = new GameObjectCategory();
			containers.id = 2;
			containers.name = "Containers";
			GameObjectCategory production = new GameObjectCategory();
			production.id = 3;
			production.name = "Refinement and Production";
			GameObjectCategory energy = new GameObjectCategory();
			energy.id = 4;
			energy.name = "Energy";
			GameObjectCategory conveyor = new GameObjectCategory();
			conveyor.id = 5;
			conveyor.name = "Conveyor";
			GameObjectCategory utility = new GameObjectCategory();
			utility.id = 6;
			utility.name = "Utility";
			GameObjectCategory weapons = new GameObjectCategory();
			weapons.id = 7;
			weapons.name = "Weapons";
			GameObjectCategory tools = new GameObjectCategory();
			tools.id = 8;
			tools.name = "Tools";
			GameObjectCategory lights = new GameObjectCategory();
			lights.id = 9;
			lights.name = "Lights";
			GameObjectCategory misc = new GameObjectCategory();
			misc.id = 10;
			misc.name = "Misc";

			//Main Types
			Register(typeof(MyObjectBuilder_RadioAntenna), typeof(AntennaEntity), utility);
			Register(typeof(MyObjectBuilder_Assembler), typeof(AssemblerEntity), production);
			Register(typeof(MyObjectBuilder_BatteryBlock), typeof(BatteryBlockEntity), energy);
			Register(typeof(MyObjectBuilder_Beacon), typeof(BeaconEntity), utility);
			Register(typeof(MyObjectBuilder_CargoContainer), typeof(CargoContainerEntity), containers);
			Register(typeof(MyObjectBuilder_Cockpit), typeof(CockpitEntity), utility);
			Register(typeof(MyObjectBuilder_Conveyor), typeof(ConveyorBlockEntity), conveyor);
			Register(typeof(MyObjectBuilder_ConveyorConnector), typeof(ConveyorTubeEntity), conveyor);
			Register(typeof(MyObjectBuilder_Door), typeof(DoorEntity), utility);
			Register(typeof(MyObjectBuilder_LargeGatlingTurret), typeof(GatlingTurretEntity), weapons);
			Register(typeof(MyObjectBuilder_GravityGenerator), typeof(GravityGeneratorEntity), utility);
			Register(typeof(MyObjectBuilder_GravityGeneratorSphere), typeof(GravitySphereEntity), utility);
			Register(typeof(MyObjectBuilder_Gyro), typeof(GyroEntity), utility);
			Register(typeof(MyObjectBuilder_InteriorLight), typeof(InteriorLightEntity), lights);
			Register(typeof(MyObjectBuilder_LandingGear), typeof(LandingGearEntity), utility);
			Register(typeof(MyObjectBuilder_MedicalRoom), typeof(MedicalRoomEntity), utility);
			Register(typeof(MyObjectBuilder_MergeBlock), typeof(MergeBlockEntity), utility);
			Register(typeof(MyObjectBuilder_LargeMissileTurret), typeof(MissileTurretEntity), weapons);
			Register(typeof(MyObjectBuilder_Reactor), typeof(ReactorEntity), energy);
			Register(typeof(MyObjectBuilder_Refinery), typeof(RefineryEntity), production);
			Register(typeof(MyObjectBuilder_ReflectorLight), typeof(ReflectorLightEntity), lights);
			Register(typeof(MyObjectBuilder_Drill), typeof(ShipDrillEntity), tools);
			Register(typeof(MyObjectBuilder_ShipGrinder), typeof(ShipGrinderEntity), tools);
			Register(typeof(MyObjectBuilder_ShipWelder), typeof(ShipWelderEntity), tools);
			Register(typeof(MyObjectBuilder_SolarPanel), typeof(SolarPanelEntity), energy);
			Register(typeof(MyObjectBuilder_Thrust), typeof(ThrustEntity), misc);
			Register(typeof(MyObjectBuilder_SmallGatlingGun), typeof(SmallGatlingGunEntity), weapons);
			Register(typeof(MyObjectBuilder_MotorStator), typeof(RotorEntity), misc);
			Register(typeof(MyObjectBuilder_PistonBase), typeof(PistonEntity), misc);
			Register(typeof(MyObjectBuilder_VirtualMass), typeof(VirtualMassEntity), misc);
			Register(typeof(MyObjectBuilder_CameraBlock), typeof(CameraBlockEntity), utility);
			Register(typeof(MyObjectBuilder_OreDetector), typeof(OreDetectorEntity), tools);
			Register(typeof(MyObjectBuilder_RemoteControl), typeof(ButtonPanelEntity), utility);

			//Base Types
			Register(typeof(MyObjectBuilder_CubeBlock), typeof(CubeBlockEntity), structural);
			Register(typeof(MyObjectBuilder_TerminalBlock), typeof(TerminalBlockEntity), misc);
			Register(typeof(MyObjectBuilder_FunctionalBlock), typeof(FunctionalBlockEntity), misc);
			Register(typeof(MyObjectBuilder_ProductionBlock), typeof(ProductionBlockEntity), production);
			Register(typeof(MyObjectBuilder_ShipController), typeof(ShipControllerEntity), utility);
			Register(typeof(MyObjectBuilder_TurretBase), typeof(TurretBaseEntity), weapons);
			Register(typeof(MyObjectBuilder_ShipToolBase), typeof(ShipToolBaseEntity), tools);
			Register(typeof(MyObjectBuilder_LightingBlock), typeof(LightEntity), lights);
		}
コード例 #7
0
        protected BlockRegistry()
        {
            GameObjectCategory structural = new GameObjectCategory();

            structural.id   = 1;
            structural.name = "Structural";
            GameObjectCategory containers = new GameObjectCategory();

            containers.id   = 2;
            containers.name = "Containers";
            GameObjectCategory production = new GameObjectCategory();

            production.id   = 3;
            production.name = "Refinement and Production";
            GameObjectCategory energy = new GameObjectCategory();

            energy.id   = 4;
            energy.name = "Energy";
            GameObjectCategory conveyor = new GameObjectCategory();

            conveyor.id   = 5;
            conveyor.name = "Conveyor";
            GameObjectCategory utility = new GameObjectCategory();

            utility.id   = 6;
            utility.name = "Utility";
            GameObjectCategory weapons = new GameObjectCategory();

            weapons.id   = 7;
            weapons.name = "Weapons";
            GameObjectCategory tools = new GameObjectCategory();

            tools.id   = 8;
            tools.name = "Tools";
            GameObjectCategory lights = new GameObjectCategory();

            lights.id   = 9;
            lights.name = "Lights";
            GameObjectCategory misc = new GameObjectCategory();

            misc.id   = 10;
            misc.name = "Misc";

            //Main Types
            Register(typeof(MyObjectBuilder_RadioAntenna), typeof(AntennaEntity), utility);
            Register(typeof(MyObjectBuilder_Assembler), typeof(AssemblerEntity), production);
            Register(typeof(MyObjectBuilder_BatteryBlock), typeof(BatteryBlockEntity), energy);
            Register(typeof(MyObjectBuilder_Beacon), typeof(BeaconEntity), utility);
            Register(typeof(MyObjectBuilder_CargoContainer), typeof(CargoContainerEntity), containers);
            Register(typeof(MyObjectBuilder_Cockpit), typeof(CockpitEntity), utility);
            Register(typeof(MyObjectBuilder_Conveyor), typeof(ConveyorBlockEntity), conveyor);
            Register(typeof(MyObjectBuilder_ConveyorConnector), typeof(ConveyorTubeEntity), conveyor);
            Register(typeof(MyObjectBuilder_Door), typeof(DoorEntity), utility);
            Register(typeof(MyObjectBuilder_LargeGatlingTurret), typeof(GatlingTurretEntity), weapons);
            Register(typeof(MyObjectBuilder_GravityGenerator), typeof(GravityGeneratorEntity), utility);
            Register(typeof(MyObjectBuilder_GravityGeneratorSphere), typeof(GravitySphereEntity), utility);
            Register(typeof(MyObjectBuilder_Gyro), typeof(GyroEntity), utility);
            Register(typeof(MyObjectBuilder_InteriorLight), typeof(InteriorLightEntity), lights);
            Register(typeof(MyObjectBuilder_LandingGear), typeof(LandingGearEntity), utility);
            Register(typeof(MyObjectBuilder_MedicalRoom), typeof(MedicalRoomEntity), utility);
            Register(typeof(MyObjectBuilder_MergeBlock), typeof(MergeBlockEntity), utility);
            Register(typeof(MyObjectBuilder_LargeMissileTurret), typeof(MissileTurretEntity), weapons);
            Register(typeof(MyObjectBuilder_Reactor), typeof(ReactorEntity), energy);
            Register(typeof(MyObjectBuilder_Refinery), typeof(RefineryEntity), production);
            Register(typeof(MyObjectBuilder_ReflectorLight), typeof(ReflectorLightEntity), lights);
            Register(typeof(MyObjectBuilder_Drill), typeof(ShipDrillEntity), tools);
            Register(typeof(MyObjectBuilder_ShipGrinder), typeof(ShipGrinderEntity), tools);
            Register(typeof(MyObjectBuilder_ShipWelder), typeof(ShipWelderEntity), tools);
            Register(typeof(MyObjectBuilder_SolarPanel), typeof(SolarPanelEntity), energy);
            Register(typeof(MyObjectBuilder_Thrust), typeof(ThrustEntity), misc);
            Register(typeof(MyObjectBuilder_SmallGatlingGun), typeof(SmallGatlingGunEntity), weapons);
            Register(typeof(MyObjectBuilder_MotorStator), typeof(RotorEntity), misc);
            Register(typeof(MyObjectBuilder_PistonBase), typeof(PistonEntity), misc);
            Register(typeof(MyObjectBuilder_VirtualMass), typeof(VirtualMassEntity), misc);
            Register(typeof(MyObjectBuilder_CameraBlock), typeof(CameraBlockEntity), utility);
            Register(typeof(MyObjectBuilder_OreDetector), typeof(OreDetectorEntity), tools);
            Register(typeof(MyObjectBuilder_RemoteControl), typeof(ButtonPanelEntity), utility);

            //Base Types
            Register(typeof(MyObjectBuilder_CubeBlock), typeof(CubeBlockEntity), structural);
            Register(typeof(MyObjectBuilder_TerminalBlock), typeof(TerminalBlockEntity), misc);
            Register(typeof(MyObjectBuilder_FunctionalBlock), typeof(FunctionalBlockEntity), misc);
            Register(typeof(MyObjectBuilder_ProductionBlock), typeof(ProductionBlockEntity), production);
            Register(typeof(MyObjectBuilder_ShipController), typeof(ShipControllerEntity), utility);
            Register(typeof(MyObjectBuilder_TurretBase), typeof(TurretBaseEntity), weapons);
            Register(typeof(MyObjectBuilder_ShipToolBase), typeof(ShipToolBaseEntity), tools);
            Register(typeof(MyObjectBuilder_LightingBlock), typeof(LightEntity), lights);
        }
コード例 #8
0
		public void Register(Type gameType, Type apiType, GameObjectCategory category)
		{
			if (apiType == null || gameType == null)
				return;
			if (!typeof(MyObjectBuilder_Base).IsAssignableFrom(gameType))
				return;
			if (!typeof(BaseObject).IsAssignableFrom(apiType))
				return;
			if (m_typeMap.ContainsKey(gameType))
				return;
			if (m_typeMap.ContainsValue(apiType))
				return;
			if (!ValidateRegistration(gameType, apiType))
				return;

			GuidAttribute guid = (GuidAttribute)Assembly.GetCallingAssembly().GetCustomAttributes(typeof(GuidAttribute), true)[0];
			Guid guidValue = new Guid(guid.Value);

			GameObjectTypeEntry entry = new GameObjectTypeEntry();
			entry.source = guidValue;
			entry.gameType = gameType;
			entry.apiType = apiType;
			entry.enabled = true;
			entry.category = category;

			m_typeMap.Add(gameType, apiType);

			if (m_registry.ContainsKey(guidValue))
			{
				HashSet<GameObjectTypeEntry> hashSet = m_registry[guidValue];
				hashSet.Add(entry);
			}
			else
			{
				HashSet<GameObjectTypeEntry> hashSet = new HashSet<GameObjectTypeEntry>();
				hashSet.Add(entry);
				m_registry.Add(guidValue, hashSet);
			}
		}