Beispiel #1
0
 public void Init(NotShipDamagableComponentData data)
 {
     m_InitData = data;
     SetMaximumHealth(data.maxHealth);
     ForceSetHealth(maximumHealth);
     SetIgnoreDamageAtStart(data.ignoreDamageAtStart);
     SetIgnoreDamageInterval(data.ignoreDamageInterval);
     SetCreateChestOnKilling(data.createChestOnKilling);
 }
Beispiel #2
0
        private static ConcurrentDictionary <string, NebulaObjectData> LoadNebulaObjects(XElement parent)
        {
            ConcurrentDictionary <string, NebulaObjectData> result = new ConcurrentDictionary <string, NebulaObjectData>();
            var lst = parent.Elements("nebula_object").Select(no => {
                NebulaObjectData nebObjData = new NebulaObjectData {
                    ID       = no.GetString("id"),
                    position = no.GetFloatArray("position").ToVector3(),
                    rotation = no.GetFloatArray("rotation").ToVector3(),
                };

                //if(no.HasAttribute("script")) {
                //    nebObjData.scriptFile = no.GetString("script");
                //}

                Dictionary <ComponentID, ComponentData> componentCollection = new Dictionary <ComponentID, ComponentData>();
                var lst2 = no.Elements("component").Select(ce => {
                    ComponentID componentID = (ComponentID)Enum.Parse(typeof(ComponentID), ce.GetString("id"));
                    switch (componentID)
                    {
                    case ComponentID.QuestChest: {
                        QuestChestComponentData data = new QuestChestComponentData(ce);
                        componentCollection.Add(componentID, data);
                    }
                    break;

                    case ComponentID.Model:
                        {
                            ComponentSubType subType = ComponentSubType.simple_model;
                            if (ce.HasAttribute("sub_type"))
                            {
                                subType = (ComponentSubType)Enum.Parse(typeof(ComponentSubType), ce.GetString("sub_type"));
                            }
                            switch (subType)
                            {
                            case ComponentSubType.simple_model:
                                {
                                    ModelComponentData model = new ModelComponentData(ce);
                                    componentCollection.Add(componentID, model);
                                }
                                break;

                            case ComponentSubType.raceable_model:
                                {
                                    RaceableModelComponentData model = new RaceableModelComponentData(ce);
                                    componentCollection.Add(componentID, model);
                                }
                                break;
                            }
                        }
                        break;

                    case ComponentID.Movable:
                        {
                            ComponentSubType subType = (ComponentSubType)Enum.Parse(typeof(ComponentSubType), ce.GetString("sub_type"));
                            switch (subType)
                            {
                            case ComponentSubType.simple_movable:
                                SimpleMovableComponentData simpleMovableComponentData = new SimpleMovableComponentData(ce);
                                componentCollection.Add(ComponentID.Movable, simpleMovableComponentData);
                                break;

                            case ComponentSubType.player_ship_movable:
                                componentCollection.Add(ComponentID.Movable, new PlayerShipMovableComponentData());
                                break;

                            case ComponentSubType.bot_ship_movable:
                                componentCollection.Add(ComponentID.Movable, new BotShipMovableComponentData());
                                break;
                            }
                        }
                        break;

                    case ComponentID.ContractMark: {
                        ComponentSubType subType = (ComponentSubType)Enum.Parse(typeof(ComponentSubType), ce.GetString("sub_type"));
                        switch (subType)
                        {
                        case ComponentSubType.kill_npc_group_contract_mark: {
                            KillNPCGroupContractMarkData killNPCGroupContractData = new KillNPCGroupContractMarkData(ce);
                            componentCollection.Add(ComponentID.ContractMark, killNPCGroupContractData);
                        }
                        break;

                        case ComponentSubType.kill_special_npc_contract_mark: {
                            KillNPCContractMarkData killNPCContractMarkData = new KillNPCContractMarkData(ce);
                            componentCollection.Add(ComponentID.ContractMark, killNPCContractMarkData);
                        }
                        break;

                        case ComponentSubType.explore_location_contract: {
                            ExploreLocationContractMarkData exploreLocationContractMarkData = new ExploreLocationContractMarkData(ce);
                            componentCollection.Add(ComponentID.ContractMark, exploreLocationContractMarkData);
                        }
                        break;

                        case ComponentSubType.found_item_contract_mark: {
                            FoundItemContractMarkData ficmData = new FoundItemContractMarkData(ce);
                            componentCollection.Add(ComponentID.ContractMark, ficmData);
                        }
                        break;
                        }
                    }
                    break;

                    case ComponentID.Activator:
                        {
                            ComponentSubType subType = (ComponentSubType)Enum.Parse(typeof(ComponentSubType), ce.GetString("sub_type"));
                            switch (subType)
                            {
                            case ComponentSubType.spawn_pirate_activator: {
                                SpawnPiratesActivatorComponentData data = new SpawnPiratesActivatorComponentData(ce);
                                componentCollection.Add(ComponentID.Activator, data);
                            }
                            break;

                            case ComponentSubType.var_activator: {
                                VariableActivatorComponentData data = new VariableActivatorComponentData(ce);
                                componentCollection.Add(ComponentID.Activator, data);
                            }
                            break;
                            }
                        }
                        break;

                    case ComponentID.LoreBox: {
                        componentCollection.Add(ComponentID.LoreBox, new LoreBoxComponentData(ce));
                    }
                    break;

                    case ComponentID.PlanetLandingTeleport: {
                        componentCollection.Add(ComponentID.PlanetLandingTeleport, new PlanetLandingTeleportData(ce));
                    }
                    break;

                    case ComponentID.CombatAI:
                        {
                            ComponentSubType subType = (ComponentSubType)Enum.Parse(typeof(ComponentSubType), ce.GetString("sub_type"));
                            switch (subType)
                            {
                            case ComponentSubType.ai_follow_path_combat:
                                {
                                    FollowPathCombatAIComponentData data = new FollowPathCombatAIComponentData(ce);
                                    componentCollection.Add(ComponentID.CombatAI, data);
                                }
                                break;

                            case ComponentSubType.ai_follow_path_non_combat:
                                {
                                    FollowPathNonCombatAIComponentData data = new FollowPathNonCombatAIComponentData(ce);
                                    componentCollection.Add(ComponentID.CombatAI, data);
                                }
                                break;

                            case ComponentSubType.ai_orbit:
                                {
                                    OrbitAIComponentData data = new OrbitAIComponentData(ce);
                                    componentCollection.Add(ComponentID.CombatAI, data);
                                }
                                break;

                            case ComponentSubType.ai_patrol:
                                {
                                    PatrolAIComponentData data = new PatrolAIComponentData(ce);
                                    componentCollection.Add(ComponentID.CombatAI, data);
                                }
                                break;

                            case ComponentSubType.ai_stay:
                                {
                                    StayAIComponentData data = new StayAIComponentData(ce);
                                    componentCollection.Add(ComponentID.CombatAI, data);
                                }
                                break;

                            case ComponentSubType.ai_wander_cube:
                                {
                                    WanderAIComponentData data = new WanderAIComponentData(ce);
                                    componentCollection.Add(ComponentID.CombatAI, data);
                                }
                                break;

                            case ComponentSubType.ai_wander_point:
                                {
                                    FreeFlyNearPointComponentData data = new FreeFlyNearPointComponentData(ce);
                                    componentCollection.Add(ComponentID.CombatAI, data);
                                }
                                break;
                            }
                        }
                        break;

                    case ComponentID.DatabaseObject:
                        {
                            DatabaseObjectComponentData data = new DatabaseObjectComponentData(ce);
                            componentCollection.Add(ComponentID.DatabaseObject, data);
                        }
                        break;

                    case ComponentID.DropList: {
                        ComponentSubType subType = (ComponentSubType)Enum.Parse(typeof(ComponentSubType), ce.GetString("sub_type"));
                        switch (subType)
                        {
                        case ComponentSubType.normal_drop_list: {
                            NormalDropListComponentData data = new NormalDropListComponentData(ce);
                            componentCollection.Add(ComponentID.DropList, data);
                        }
                        break;

                        case ComponentSubType.contract_drop_list: {
                            ContractDropListComponentData data = new ContractDropListComponentData(ce);
                            componentCollection.Add(ComponentID.DropList, data);
                        }
                        break;
                        }
                    }
                    break;

                    case ComponentID.NebulaObject:
                        {
                            NebulaObjectComponentData data = new NebulaObjectComponentData(ce);
                            componentCollection.Add(ComponentID.NebulaObject, data);
                        }
                        break;

                    case ComponentID.ContractObject: {
                        ContractObjectComponentData data = new ContractObjectComponentData(ce);
                        componentCollection.Add(ComponentID.ContractObject, data);
                    }
                    break;

                    case ComponentID.Turret:
                        {
                            TurretComponentData data = new TurretComponentData(ce);
                            componentCollection.Add(ComponentID.Turret, data);
                        }
                        break;

                    case ComponentID.Raceable:
                        {
                            RaceableComponentData data = new RaceableComponentData(ce);
                            componentCollection.Add(ComponentID.Raceable, data);
                        }
                        break;

                    case ComponentID.Bonuses:
                        {
                            BonusesComponentData data = new BonusesComponentData(ce);
                            componentCollection.Add(ComponentID.Bonuses, data);
                        }
                        break;

                    case ComponentID.Respawnable:
                        {
                            RespwanableComponentData data = new RespwanableComponentData(ce);
                            componentCollection.Add(ComponentID.Respawnable, data);
                        }
                        break;

                    case ComponentID.Outpost:
                        {
                            OutpostComponentData data = new OutpostComponentData(ce);
                            componentCollection.Add(ComponentID.Outpost, data);
                        }
                        break;

                    case ComponentID.Target:
                        {
                            TargetComponentData data = new TargetComponentData(ce);
                            componentCollection.Add(ComponentID.Target, data);
                        }
                        break;

                    case ComponentID.Energy:
                        {
                            EnergyComponentData data = new EnergyComponentData(ce);
                            componentCollection.Add(ComponentID.Energy, data);
                        }
                        break;

                    case ComponentID.MiningStation:
                        {
                            MiningStationComponentData data = new MiningStationComponentData(ce);
                            componentCollection.Add(ComponentID.MiningStation, data);
                        }
                        break;

                    case ComponentID.Bot:
                        {
                            BotComponentData data = new BotComponentData(ce);
                            componentCollection.Add(ComponentID.Bot, data);
                        }
                        break;

                    case ComponentID.Asteroid:
                        {
                            AsteroidComponentData data = new AsteroidComponentData(ce);
                            componentCollection.Add(ComponentID.Asteroid, data);
                        }
                        break;

                    case ComponentID.Skills:
                        {
                            SkillsComponentData data = new SkillsComponentData(ce);
                            componentCollection.Add(ComponentID.Skills, data);
                        }
                        break;

                    case ComponentID.PlayerAI:
                        {
                            PlayerAIStateComponentData data = new PlayerAIStateComponentData(ce);
                            componentCollection.Add(ComponentID.PlayerAI, data);
                        }
                        break;

                    case ComponentID.Planet:
                        {
                            PlanetObjectComponentData data = new PlanetObjectComponentData(ce);
                            componentCollection.Add(ComponentID.Planet, data);
                        }
                        break;

                    case ComponentID.Trigger: {
                        LocationTriggerComponentData data = new LocationTriggerComponentData(ce);
                        componentCollection.Add(ComponentID.Trigger, data);
                    }
                    break;

                    case ComponentID.Ship:
                        {
                            ComponentSubType subType = (ComponentSubType)Enum.Parse(typeof(ComponentSubType), ce.GetString("sub_type"));
                            switch (subType)
                            {
                            case ComponentSubType.ship_bot:
                                {
                                    BotShipComponentData data = new BotShipComponentData(ce);
                                    componentCollection.Add(ComponentID.Ship, data);
                                }
                                break;

                            case ComponentSubType.special_ship_bot: {
                                SpecialBotShipComponentData data = new SpecialBotShipComponentData(ce);
                                componentCollection.Add(ComponentID.Ship, data);
                            }
                            break;
                            }
                        }
                        break;

                    case ComponentID.Weapon:
                        {
                            ComponentSubType subType = (ComponentSubType)Enum.Parse(typeof(ComponentSubType), ce.GetString("sub_type"));
                            switch (subType)
                            {
                            case ComponentSubType.weapon_ship:
                                {
                                    ShipWeaponComponentData data = new ShipWeaponComponentData(ce);
                                    componentCollection.Add(ComponentID.Weapon, data);
                                }
                                break;

                            case ComponentSubType.weapon_simple:
                                {
                                    SimpleWeaponComponentData data = new SimpleWeaponComponentData(ce);
                                    componentCollection.Add(ComponentID.Weapon, data);
                                }
                                break;

                            case ComponentSubType.special_ship_weapon: {
                                SpecialShipWeaponComponentData data = new SpecialShipWeaponComponentData(ce);
                                componentCollection.Add(ComponentID.Weapon, data);
                            }
                            break;
                            }
                        }
                        break;

                    case ComponentID.Damagable:
                        {
                            ComponentSubType subType = (ComponentSubType)Enum.Parse(typeof(ComponentSubType), ce.GetString("sub_type"));
                            switch (subType)
                            {
                            case ComponentSubType.damagable_not_ship:
                                {
                                    NotShipDamagableComponentData data = new NotShipDamagableComponentData(ce);
                                    componentCollection.Add(ComponentID.Damagable, data);
                                }
                                break;

                            case ComponentSubType.damagable_ship:
                                {
                                    ShipDamagableComponentData data = new ShipDamagableComponentData(ce);
                                    componentCollection.Add(ComponentID.Damagable, data);
                                }
                                break;

                            case ComponentSubType.damagable_fixed_damage:
                                {
                                    FixedInputDamageDamagableComponentData data = new FixedInputDamageDamagableComponentData(ce);
                                    componentCollection.Add(ComponentID.Damagable, data);
                                }
                                break;

                            case ComponentSubType.damagable_outpost:
                                {
                                    OutpostDamagableComponentData data = new OutpostDamagableComponentData(ce);
                                    componentCollection.Add(ComponentID.Damagable, data);
                                }
                                break;
                            }
                        }
                        break;

                    case ComponentID.Character:
                        {
                            ComponentSubType subType = (ComponentSubType)Enum.Parse(typeof(ComponentSubType), ce.GetString("sub_type"));
                            switch (subType)
                            {
                            case ComponentSubType.character_bot:
                                {
                                    BotCharacterComponentData data = new BotCharacterComponentData(ce);
                                    componentCollection.Add(ComponentID.Character, data);
                                }
                                break;

                            case ComponentSubType.character_player:
                                {
                                    PlayerCharacterComponentData data = new PlayerCharacterComponentData(ce);
                                    componentCollection.Add(ComponentID.Character, data);
                                }
                                break;
                            }
                        }
                        break;

                    case ComponentID.MainOutpost:
                        {
                            MainOutpostComponentData data = new MainOutpostComponentData(ce);
                            componentCollection.Add(ComponentID.MainOutpost, data);
                        }
                        break;

                    case ComponentID.SharedChest:
                        {
                            SharedChestComponentData data = new SharedChestComponentData(ce);
                            componentCollection.Add(ComponentID.SharedChest, data);
                        }
                        break;

                    case ComponentID.PvpStore:
                        {
                            PvpStoreComponentData data = new PvpStoreComponentData(ce);
                            componentCollection.Add(ComponentID.PvpStore, data);
                        }
                        break;

                    case ComponentID.Teleport:
                        {
                            ComponentSubType subType = ComponentSubType.SimpleTeleport;
                            if (ce.HasAttribute("sub_type"))
                            {
                                subType = (ComponentSubType)Enum.Parse(typeof(ComponentSubType), ce.GetString("sub_type"));
                            }
                            switch (subType)
                            {
                            case ComponentSubType.PersonalTeleport:
                                {
                                    PersonalBeaconComponentData data = new PersonalBeaconComponentData(ce);
                                    componentCollection.Add(ComponentID.Teleport, data);
                                }
                                break;

                            case ComponentSubType.SimpleTeleport:
                                {
                                    TeleportComponentData data = new TeleportComponentData(ce);
                                    componentCollection.Add(ComponentID.Teleport, data);
                                }
                                break;
                            }
                        }
                        break;

                    case ComponentID.SubZone:
                        {
                            SubZoneComponentData data = new SubZoneComponentData(ce);
                            componentCollection.Add(ComponentID.SubZone, data);
                        }
                        break;

                    case ComponentID.Station:
                        {
                            StationComponentData data = new StationComponentData(ce);
                            componentCollection.Add(ComponentID.Station, data);
                        }
                        break;
                    }
                    return(componentID);
                }).ToList();
                nebObjData.componentCollection = componentCollection;
                result.TryAdd(nebObjData.ID, nebObjData);

                return(nebObjData.ID);
            }).ToList();

            return(result);
        }