コード例 #1
0
ファイル: City.cs プロジェクト: LeaderEnemyBoss/ELCP
    public void AddRegionalEffect(RegionalEffect effect)
    {
        this.regionalEffects.Add(effect);
        for (int i = 0; i < effect.Definition.Descriptors.Length; i++)
        {
            base.AddDescriptor(effect.Definition.Descriptors[i], true);
        }
        this.Refresh(false);
        IEventService service = Services.GetService <IEventService>();

        if (service != null)
        {
            IGameEntityRepositoryService service2 = this.gameService.Game.Services.GetService <IGameEntityRepositoryService>();
            if (service2 != null)
            {
                Kaiju kaiju = null;
                service2.TryGetValue <Kaiju>(effect.OwnerGUID, out kaiju);
                if (kaiju != null)
                {
                    EventCityAddRegionalEffects eventToNotify = new EventCityAddRegionalEffects(this.Empire, this, kaiju);
                    service.Notify(eventToNotify);
                }
            }
        }
    }
    protected override bool Initialize(QuestBehaviour questBehaviour)
    {
        IGameService service = Services.GetService <IGameService>();

        if (service == null || service.Game == null || !(service.Game is global::Game))
        {
            Diagnostics.LogError("Unable to retrieve the game service.");
            return(false);
        }
        IGameEntityRepositoryService service2 = service.Game.Services.GetService <IGameEntityRepositoryService>();

        if (service2 == null)
        {
            Diagnostics.LogError("Unable to retrieve the game entity repository service.");
            return(false);
        }
        if (!this.TryResolveTarget(questBehaviour))
        {
            return(false);
        }
        if (this.QuestMarkerGUID == 0UL)
        {
            this.QuestMarkerGUID = service2.GenerateGUID();
        }
        QuestVariable questVariable = questBehaviour.GetQuestVariableByName(this.Output_QuestMarkerVarName);

        if (questVariable == null)
        {
            questVariable = new QuestVariable(this.Output_QuestMarkerVarName);
            questBehaviour.QuestVariables.Add(questVariable);
        }
        questVariable.Object = this.QuestMarkerGUID;
        return(base.Initialize(questBehaviour));
    }
コード例 #3
0
    private void ListNearbyCreepingNodesFiltered(Army army)
    {
        if (army == null)
        {
            throw new ArgumentNullException("army");
        }
        this.creepingNodes.Clear();
        IGameService service = Services.GetService <IGameService>();

        Diagnostics.Assert(service != null);
        global::Game game = service.Game as global::Game;

        Diagnostics.Assert(game != null);
        IWorldPositionningService service2 = service.Game.Services.GetService <IWorldPositionningService>();

        Diagnostics.Assert(service2 != null);
        IGameEntityRepositoryService service3 = service.Game.Services.GetService <IGameEntityRepositoryService>();

        Diagnostics.Assert(service3 != null);
        List <StaticString>  list       = new List <StaticString>();
        List <WorldPosition> neighbours = army.WorldPosition.GetNeighbours(game.World.WorldParameters);

        for (int i = 0; i < neighbours.Count; i++)
        {
            PointOfInterest pointOfInterest = service2.GetPointOfInterest(neighbours[i]);
            if (pointOfInterest != null && pointOfInterest.CreepingNodeGUID != GameEntityGUID.Zero)
            {
                CreepingNode creepingNode = null;
                if (service3.TryGetValue <CreepingNode>(pointOfInterest.CreepingNodeGUID, out creepingNode) && this.CanToggleOverCreepingNode(army, creepingNode, ref list) && !this.creepingNodes.Contains(creepingNode))
                {
                    this.creepingNodes.Add(creepingNode);
                }
            }
        }
    }
コード例 #4
0
ファイル: Kaiju.cs プロジェクト: LeaderEnemyBoss/ELCP
    public void RegisterTroops()
    {
        IGameService service = Services.GetService <IGameService>();
        IGameEntityRepositoryService service2 = service.Game.Services.GetService <IGameEntityRepositoryService>();

        if (this.KaijuArmy != null)
        {
            foreach (Unit unit in this.KaijuArmy.Units)
            {
                if (!service2.Contains(unit.GUID))
                {
                    service2.Register(unit);
                }
            }
        }
        if (this.KaijuGarrison != null)
        {
            foreach (Unit unit2 in this.KaijuGarrison.Units)
            {
                if (!service2.Contains(unit2.GUID))
                {
                    service2.Register(unit2);
                }
            }
        }
    }
    protected override State Execute(QuestBehaviour questBehaviour, params object[] parameters)
    {
        global::Empire empire2 = this.Game.Empires.FirstOrDefault((global::Empire empire) => empire.Bits == questBehaviour.Quest.EmpireBits);

        if (empire2 == null)
        {
            Diagnostics.LogError("Failed to retrieve the (lesser) quest empire.");
            return(State.Running);
        }
        ulong num;

        if (questBehaviour.TryGetQuestVariableValueByName <ulong>(this.ArmyGUIDVarName, out num) && num != 0UL)
        {
            IGameEntityRepositoryService service = this.Game.Services.GetService <IGameEntityRepositoryService>();
            IGameEntity gameEntity = null;
            if (!service.TryGetValue(num, out gameEntity))
            {
                Diagnostics.LogWarning("Action failed getting the targeted Army");
                return(State.Success);
            }
            Army army = gameEntity as Army;
            if (army == null)
            {
                Diagnostics.LogError("Action failed getting the targeted Army");
                return(State.Success);
            }
            OrderDestroyArmy orderDestroyArmy = new OrderDestroyArmy(army.Empire.Index, num);
            Diagnostics.Log("Posting order: {0}.", new object[]
            {
                orderDestroyArmy.ToString()
            });
            empire2.PlayerControllers.Server.PostOrder(orderDestroyArmy);
        }
        return(State.Success);
    }
コード例 #6
0
    protected override bool Initialize(QuestBehaviour questBehaviour)
    {
        if (string.IsNullOrEmpty(this.ConstructionName))
        {
            if (string.IsNullOrEmpty(this.ConstructionNameVarName))
            {
                Diagnostics.LogError("Missing attribute 'ConstructionNameVarName'");
                return(false);
            }
            string text;
            if (!questBehaviour.TryGetQuestVariableValueByName <string>(this.ConstructionNameVarName, out text))
            {
                Diagnostics.LogError("Cannot retrieve quest variable (varname: '{0}')", new object[]
                {
                    this.ConstructionNameVarName
                });
                return(false);
            }
            if (string.IsNullOrEmpty(text))
            {
                Diagnostics.LogError("Construction name is null or empty (varname: '{0}')", new object[]
                {
                    this.ConstructionNameVarName
                });
                return(false);
            }
            this.ConstructionName = text;
        }
        if (this.CityGUID != GameEntityGUID.Zero && !string.IsNullOrEmpty(this.Output_CityVarName) && !questBehaviour.QuestVariables.Exists((QuestVariable match) => match.Name == this.Output_CityVarName))
        {
            IGameService service = Services.GetService <IGameService>();
            if (service == null)
            {
                Diagnostics.LogError("Unable to retrieve the game service.");
                return(false);
            }
            IGameEntityRepositoryService service2 = service.Game.Services.GetService <IGameEntityRepositoryService>();
            if (service2 == null)
            {
                Diagnostics.LogError("Unable to retrieve the game entity repository service.");
                return(false);
            }
            City @object;
            if (service2.TryGetValue <City>(this.CityGUID, out @object))
            {
                QuestVariable questVariable = new QuestVariable(this.Output_CityVarName);
                questVariable.Object = @object;
                questBehaviour.QuestVariables.Add(questVariable);
            }
        }
        City city = null;

        if (this.CityGUID == GameEntityGUID.Zero && !string.IsNullOrEmpty(this.TargetCityVarName) && questBehaviour.TryGetQuestVariableValueByName <City>(this.TargetCityVarName, out city))
        {
            this.CityGUID = city.GUID;
        }
        return(base.Initialize(questBehaviour));
    }
コード例 #7
0
    protected override IEnumerator OnLoadGame()
    {
        yield return(base.OnLoadGame());

        IGameEntityRepositoryService gameEntityRepositoryService = base.Game.Services.GetService <IGameEntityRepositoryService>();

        this.temporaryGuid = gameEntityRepositoryService.GenerateGUID();
        this.EncounterRepositoryService = ((global::Game)base.Game).Services.GetService <IEncounterRepositoryService>();
        this.EndTurnService             = Services.GetService <IEndTurnService>();
        yield break;
    }
コード例 #8
0
ファイル: HeroPool.cs プロジェクト: LeaderEnemyBoss/ELCP
    public override IEnumerator BindServices(IServiceContainer serviceContainer)
    {
        yield return(base.BindServices(serviceContainer));

        yield return(base.BindService <IGameEntityRepositoryService>(serviceContainer, delegate(IGameEntityRepositoryService gameEntityRepositoryService)
        {
            this.GameEntityRepositoryService = gameEntityRepositoryService;
        }));

        serviceContainer.AddService <IHeroManagementService>(this);
        yield break;
    }
コード例 #9
0
ファイル: Kaiju.cs プロジェクト: LeaderEnemyBoss/ELCP
    public IEnumerator OnLoadGame(Amplitude.Unity.Game.Game game)
    {
        IGameEntityRepositoryService service = game.Services.GetService <IGameEntityRepositoryService>();

        if (this.kaijuArmyGUID != GameEntityGUID.Zero)
        {
            Army army = this.Empire.GetAgency <DepartmentOfDefense>().GetArmy(this.kaijuArmyGUID);
            if (army != null && army is KaijuArmy)
            {
                KaijuArmy kaijuArmy = army as KaijuArmy;
                if (kaijuArmy != null)
                {
                    this.SetArmy(kaijuArmy);
                }
            }
        }
        if (this.KaijuGarrison != null)
        {
            if (this.OnGarrisonMode())
            {
                Region region = game.Services.GetService <IWorldPositionningService>().GetRegion(this.KaijuGarrison.WorldPosition);
                this.Region = region;
                this.Region.KaijuGarrisonGUID = this.KaijuGarrison.GUID;
                this.Region.KaijuEmpire       = this.KaijuGarrison.KaijuEmpire;
            }
        }
        else
        {
            Diagnostics.LogError("KaijuGarrison was not loaded properly.");
        }
        if (this.OnGarrisonMode())
        {
            service.Register(this.KaijuGarrison);
            service.Unregister(this.KaijuArmy);
            this.HideKaijuArmyFromMap();
            this.Empire.RemoveChild(this.KaijuArmy);
        }
        else if (this.OnArmyMode())
        {
            service.Register(this.KaijuArmy);
            service.Unregister(this.KaijuGarrison);
            this.ShowKaijuArmyInMap();
        }
        this.RegisterTroops();
        this.ComputeNextTurnToRecoverFromStun();
        this.ComputeNextTurnToSpawnUnits(false);
        this.KaijuArmy.ForceWorldOrientation(this.WorldOrientation);
        this.KaijuGarrison.ForceWorldOrientation(this.WorldOrientation);
        yield break;
    }
コード例 #10
0
    private CreepingNode GetCreepingNodeFromPOI(PointOfInterest pointOfInterest)
    {
        CreepingNode result = null;

        if (pointOfInterest != null && pointOfInterest.CreepingNodeGUID != GameEntityGUID.Zero)
        {
            IGameService service = Services.GetService <IGameService>();
            Diagnostics.Assert(service != null);
            IGameEntityRepositoryService service2 = service.Game.Services.GetService <IGameEntityRepositoryService>();
            Diagnostics.Assert(service2 != null);
            service2.TryGetValue <CreepingNode>(pointOfInterest.CreepingNodeGUID, out result);
            return(result);
        }
        return(result);
    }
コード例 #11
0
    public override void ReadXml(XmlReader reader)
    {
        GameEntityGUID guid = reader.GetAttribute <ulong>("TargetGUID");

        if (guid.IsValid)
        {
            IGameService service = Services.GetService <IGameService>();
            Diagnostics.Assert(service != null);
            IGameEntityRepositoryService service2 = service.Game.Services.GetService <IGameEntityRepositoryService>();
            Diagnostics.Assert(service2 != null);
            IGameEntity gameEntity;
            service2.TryGetValue(guid, out gameEntity);
            this.TargetCamp = (gameEntity as Camp);
        }
        base.ReadXml(reader);
    }
コード例 #12
0
    private Unit FetchHero()
    {
        Unit result = null;
        GuiNotificationHeroBase guiNotificationHeroBase = this.guiNotification as GuiNotificationHeroBase;

        if (guiNotificationHeroBase != null)
        {
            IGameEntityRepositoryService service = base.Game.Services.GetService <IGameEntityRepositoryService>();
            IGameEntity gameEntity = null;
            if (service.TryGetValue(guiNotificationHeroBase.HeroGuid, out gameEntity))
            {
                result = (gameEntity as Unit);
            }
        }
        return(result);
    }
    protected override bool Initialize(QuestBehaviour questBehaviour)
    {
        IGameService service = Services.GetService <IGameService>();
        global::Game game    = service.Game as global::Game;

        if (service == null || service.Game == null || !(service.Game is global::Game))
        {
            Diagnostics.LogError("Unable to retrieve the game service.");
            return(false);
        }
        IGameEntityRepositoryService service2 = service.Game.Services.GetService <IGameEntityRepositoryService>();

        if (service2 == null)
        {
            Diagnostics.LogError("Unable to retrieve the game entity repository service.");
            return(false);
        }
        IEnumerable <WorldPosition> source;

        if (this.DevicePositions == null && questBehaviour.TryGetQuestVariableValueByName <WorldPosition>(this.DevicePositionVarName, out source))
        {
            this.DevicePositions = source.ToArray <WorldPosition>();
        }
        if (this.EntityGUID == 0UL)
        {
            this.EntityGUID = service2.GenerateGUID();
        }
        QuestVariable questVariable = questBehaviour.GetQuestVariableByName(this.Output_EntityVarName);

        if (questVariable == null)
        {
            questVariable = new QuestVariable(this.Output_EntityVarName);
            questBehaviour.QuestVariables.Add(questVariable);
            IQuestManagementService service3 = game.Services.GetService <IQuestManagementService>();
            if (service3 != null)
            {
                QuestVariable questVariable2 = new QuestVariable(this.Output_EntityVarName, this.EntityGUID);
                service3.State.AddGlobalVariable(questBehaviour.Initiator.Index, questVariable2);
            }
        }
        questVariable.Object = this.EntityGUID;
        return(base.Initialize(questBehaviour));
    }
コード例 #14
0
    public override void ReadXml(XmlReader reader)
    {
        int attribute = reader.GetAttribute <int>("RegionTargetIndex");

        this.attackKaijuMessageId = reader.GetAttribute <ulong>("AttackKaijuMessageId");
        GameEntityGUID guid = reader.GetAttribute <ulong>("TargetGUID");

        if (guid.IsValid)
        {
            IGameService service = Services.GetService <IGameService>();
            Diagnostics.Assert(service != null);
            IGameEntityRepositoryService service2 = service.Game.Services.GetService <IGameEntityRepositoryService>();
            Diagnostics.Assert(service2 != null);
            IGameEntity gameEntity;
            service2.TryGetValue(guid, out gameEntity);
            this.kaiju = (gameEntity as Kaiju);
            Diagnostics.Assert(this.kaiju != null);
        }
        base.ReadXml(reader);
    }
コード例 #15
0
 public override void ReadXml(XmlReader reader)
 {
     base.ReadXml(reader);
     if (reader.IsStartElement("PointOfInterests"))
     {
         IGameEntityRepositoryService service = Services.GetService <IGameService>().Game.Services.GetService <IGameEntityRepositoryService>();
         int attribute = reader.GetAttribute <int>("Count");
         reader.ReadStartElement("PointOfInterests");
         this.pointOfInterests.Clear();
         for (int i = 0; i < attribute; i++)
         {
             GameEntityGUID  guid = reader.ReadElementString <ulong>("PointOfInterestGUID");
             PointOfInterest item = null;
             if (service.TryGetValue <PointOfInterest>(guid, out item))
             {
                 this.pointOfInterests.Add(item);
             }
         }
         reader.ReadEndElement("PointOfInterests");
     }
 }
コード例 #16
0
ファイル: MajorEmpire.cs プロジェクト: LeaderEnemyBoss/ELCP
	protected override IEnumerator OnLoadGame(Amplitude.Unity.Game.Game game)
	{
		IGameEntityRepositoryService gameEntityRepositoryService = game.Services.GetService<IGameEntityRepositoryService>();
		Diagnostics.Assert(gameEntityRepositoryService != null);
		Diagnostics.Assert(game.Services.GetService<IWorldPositionningService>() != null);
		if (this.TamedKaijus != null)
		{
			int num;
			for (int index = 0; index < this.TamedKaijus.Count; index = num + 1)
			{
				Kaiju kaiju = this.TamedKaijus[index];
				if (kaiju != null)
				{
					KaijuEmpire kaijuEmpire = (game as global::Game).Empires[kaiju.KaijuEmpireIndex] as KaijuEmpire;
					kaiju.KaijuEmpire = kaijuEmpire;
					yield return kaiju.OnLoadGame(game);
					kaiju.MajorEmpire = this;
					base.AddChild(kaiju);
					gameEntityRepositoryService.Register(kaiju);
					DepartmentOfTheInterior.GenerateResourcesLeechingForTamedKaijus(kaiju);
				}
				kaiju = null;
				num = index;
				kaiju = null;
				kaiju = null;
				kaiju = null;
				kaiju = null;
			}
			this.Refresh(false);
		}
		this.IsSpectator = (base.Faction.Name == "FactionELCPSpectator");
		this.ELCPIsEliminated = this.IsEliminated;
		if (this.ELCPIsEliminated)
		{
			ELCPUtilities.EliminatedEmpireIndices.Add(base.Index);
		}
		yield return base.OnLoadGame(game);
		yield break;
	}
コード例 #17
0
    bool IWorldEntityMappingOverride.TryResolve(out InterpreterContext context)
    {
        SimulationObject simulationObject = null;
        IGameService     service          = Services.GetService <IGameService>();

        if (service != null)
        {
            IGameEntityRepositoryService service2 = service.Game.Services.GetService <IGameEntityRepositoryService>();
            IGameEntity gameEntity;
            if (service2 != null && service2.TryGetValue(this.BoundTargetGUID, out gameEntity))
            {
                SimulationObjectWrapper simulationObjectWrapper = gameEntity as SimulationObjectWrapper;
                if (simulationObjectWrapper != null)
                {
                    simulationObject = simulationObjectWrapper.SimulationObject;
                }
            }
        }
        context = new InterpreterContext(simulationObject);
        context.Register("WorldMarkerType", this.MarkerTypeName);
        return(true);
    }
    protected override bool Initialize(QuestBehaviour questBehaviour)
    {
        IGameService service = Services.GetService <IGameService>();

        if (service == null)
        {
            Diagnostics.LogError("Unable to retrieve the game service.");
            return(false);
        }
        this.GameEntityRepositoryService = service.Game.Services.GetService <IGameEntityRepositoryService>();
        if (this.GameEntityRepositoryService == null)
        {
            Diagnostics.LogError("Unable to retrieve the game entity repository service.");
            return(false);
        }
        District @object;

        if (this.DistrictGUID != GameEntityGUID.Zero && !string.IsNullOrEmpty(this.Output_DistrictSimObjectVarName) && !questBehaviour.QuestVariables.Exists((QuestVariable match) => match.Name == this.Output_DistrictSimObjectVarName) && this.GameEntityRepositoryService.TryGetValue <District>(this.DistrictGUID, out @object))
        {
            QuestVariable questVariable = new QuestVariable(this.Output_DistrictSimObjectVarName);
            questVariable.Object = @object;
            questBehaviour.QuestVariables.Add(questVariable);
        }
        City object2;

        if (this.CityGUID != GameEntityGUID.Zero && !string.IsNullOrEmpty(this.Output_CityVarName) && !questBehaviour.QuestVariables.Exists((QuestVariable match) => match.Name == this.Output_CityVarName) && this.GameEntityRepositoryService.TryGetValue <City>(this.CityGUID, out object2))
        {
            QuestVariable questVariable2 = new QuestVariable(this.Output_CityVarName);
            questVariable2.Object = object2;
            questBehaviour.QuestVariables.Add(questVariable2);
        }
        City city = null;

        if (this.CityGUID == GameEntityGUID.Zero && !string.IsNullOrEmpty(this.TargetCityVarName) && questBehaviour.TryGetQuestVariableValueByName <City>(this.TargetCityVarName, out city) && city != null)
        {
            this.CityGUID = city.GUID;
        }
        return(base.Initialize(questBehaviour));
    }
コード例 #19
0
    private void GenerateUnit(global::Empire empire)
    {
        if (this.temporaryUnit != null)
        {
            this.Reset();
        }
        this.empire = empire;
        UnitDesign unitDesign = new UnitDesign();

        unitDesign.UnitBodyDefinitionReference = new XmlNamedReference(this.UnitBody.Name);
        DepartmentOfDefense agency = empire.GetAgency <DepartmentOfDefense>();

        if (!UnitGuiItem.temporaryUnitGuid.IsValid)
        {
            IGameService service = Services.GetService <IGameService>();
            IGameEntityRepositoryService service2 = service.Game.Services.GetService <IGameEntityRepositoryService>();
            UnitGuiItem.temporaryUnitGuid = service2.GenerateGUID();
        }
        this.temporaryUnit = agency.CreateTemporaryUnit(UnitGuiItem.temporaryUnitGuid, unitDesign);
        this.temporaryUnit.Rename(this.temporaryUnit.Name + "#" + this.UnitBody.Name);
        this.temporaryUnit.SimulationObject.ModifierForward = ModifierForwardType.ChildrenOnly;
        this.empire.AddChild(this.temporaryUnit);
    }
コード例 #20
0
    public void ClearFortressUnits()
    {
        IGameEntityRepositoryService service = this.gameService.Game.Services.GetService <IGameEntityRepositoryService>();

        if (this.StandardUnits.Count > 0)
        {
            Diagnostics.LogWarning("We are swapping a city which is not empty; this should not happen. All remaining units will be scraped.");
            while (this.StandardUnits.Count > 0)
            {
                Unit unit = this.StandardUnits[0];
                this.RemoveUnit(unit);
                service.Unregister(unit);
                unit.Dispose();
            }
        }
        if (this.Hero != null)
        {
            DepartmentOfEducation agency = this.Empire.GetAgency <DepartmentOfEducation>();
            if (agency != null)
            {
                agency.UnassignHero(this.Hero);
            }
        }
    }
コード例 #21
0
    protected override State Execute(AIBehaviorTree aiBehaviorTree, params object[] parameters)
    {
        IGameService service = Services.GetService <IGameService>();

        Diagnostics.Assert(service != null);
        IGameEntityRepositoryService service2 = service.Game.Services.GetService <IGameEntityRepositoryService>();

        if (this.orderTicket != null)
        {
            if (!this.orderTicket.Raised)
            {
                return(State.Running);
            }
            if (this.orderTicket.PostOrderResponse == PostOrderResponse.PreprocessHasFailed)
            {
                this.orderTicket         = null;
                aiBehaviorTree.ErrorCode = 1;
                return(State.Failure);
            }
            this.orderTicket = null;
            return(State.Success);
        }
        else
        {
            Army army;
            if (base.GetArmyUnlessLocked(aiBehaviorTree, "$Army", out army) != AIArmyMission.AIArmyMissionErrorCode.None)
            {
                return(State.Failure);
            }
            if (army.IsDismantlingDevice)
            {
                aiBehaviorTree.ErrorCode = 37;
                return(State.Failure);
            }
            if (!aiBehaviorTree.Variables.ContainsKey(this.TargetVarName))
            {
                aiBehaviorTree.LogError("${0} not set", new object[]
                {
                    this.TargetVarName
                });
                return(State.Failure);
            }
            IGameEntity gameEntity = aiBehaviorTree.Variables[this.TargetVarName] as IGameEntity;
            if (!(gameEntity is IWorldPositionable) || !(gameEntity is TerraformDevice))
            {
                aiBehaviorTree.ErrorCode = 10;
                return(State.Failure);
            }
            if (!service2.Contains(gameEntity.GUID))
            {
                return(State.Success);
            }
            if ((gameEntity as TerraformDevice).TurnsToActivate() < 1999)
            {
                return(State.Success);
            }
            if ((gameEntity as TerraformDevice).DismantlingArmy != null)
            {
                aiBehaviorTree.ErrorCode = 37;
                return(State.Failure);
            }
            Diagnostics.Assert(AIScheduler.Services != null);
            if (service.Game.Services.GetService <IWorldPositionningService>().GetDistance(army.WorldPosition, (gameEntity as IWorldPositionable).WorldPosition) != 1)
            {
                aiBehaviorTree.ErrorCode = 12;
                return(State.Failure);
            }
            IEncounterRepositoryService service3 = service.Game.Services.GetService <IEncounterRepositoryService>();
            if (service3 != null)
            {
                IEnumerable <Encounter> enumerable = service3;
                if (enumerable != null && enumerable.Any((Encounter encounter) => encounter.IsGarrisonInEncounter(army.GUID, false)))
                {
                    return(State.Running);
                }
            }
            OrderToggleDismantleDevice order = new OrderToggleDismantleDevice(army.Empire.Index, army.GUID, gameEntity.GUID, true);
            aiBehaviorTree.AICommander.Empire.PlayerControllers.AI.PostOrder(order, out this.orderTicket, null);
            return(State.Running);
        }
    }
コード例 #22
0
    protected override State Execute(AIBehaviorTree aiBehaviorTree, params object[] parameters)
    {
        Army army2;

        base.GetArmyUnlessLocked(aiBehaviorTree, "$Army", out army2);
        IGameService service = Services.GetService <IGameService>();

        Diagnostics.Assert(service != null);
        IGameEntityRepositoryService service2 = service.Game.Services.GetService <IGameEntityRepositoryService>();
        State result;

        if (this.orderTicket != null)
        {
            if (!this.orderTicket.Raised)
            {
                result = State.Running;
            }
            else
            {
                OrderInteractWith orderInteractWith = this.orderTicket.Order as OrderInteractWith;
                IGameEntity       gameEntity        = null;
                if (this.orderTicket.PostOrderResponse != PostOrderResponse.Processed)
                {
                    if (service2.TryGetValue(orderInteractWith.TargetGUID, out gameEntity))
                    {
                        PointOfInterest pointOfInterest;
                        if (gameEntity is Village)
                        {
                            pointOfInterest = (gameEntity as Village).PointOfInterest;
                        }
                        else
                        {
                            pointOfInterest = (gameEntity as PointOfInterest);
                        }
                        if (pointOfInterest != null)
                        {
                            IQuestRepositoryService service3 = service.Game.Services.GetService <IQuestRepositoryService>();
                            foreach (QuestMarker questMarker in service.Game.Services.GetService <IQuestManagementService>().GetMarkersByBoundTargetGUID(pointOfInterest.GUID))
                            {
                                Quest quest;
                                if (service3.TryGetValue(questMarker.QuestGUID, out quest) && quest.QuestDefinition.Name == "GlobalQuestCoop#0004" && quest.EmpireBits == army2.Empire.Bits && questMarker.IsVisibleFor(army2.Empire))
                                {
                                    this.orderTicket = null;
                                    QuestBehaviour questBehaviour = service3.GetQuestBehaviour(quest.Name, army2.Empire.Index);
                                    if (questBehaviour != null)
                                    {
                                        if (quest.QuestDefinition.Variables.First((QuestVariableDefinition p) => p.VarName == "$NameOfStrategicResourceToGather1") != null)
                                        {
                                            QuestBehaviourTreeNode_ConditionCheck_HasResourceAmount questBehaviourTreeNode_ConditionCheck_HasResourceAmount;
                                            if (!ELCPUtilities.TryGetFirstNodeOfType <QuestBehaviourTreeNode_ConditionCheck_HasResourceAmount>(questBehaviour.Root as BehaviourTreeNodeController, out questBehaviourTreeNode_ConditionCheck_HasResourceAmount))
                                            {
                                                break;
                                            }
                                            string resourceName            = questBehaviourTreeNode_ConditionCheck_HasResourceAmount.ResourceName;
                                            int    wantedAmount            = questBehaviourTreeNode_ConditionCheck_HasResourceAmount.WantedAmount;
                                            DepartmentOfTheTreasury agency = army2.Empire.GetAgency <DepartmentOfTheTreasury>();
                                            if (agency == null)
                                            {
                                                break;
                                            }
                                            float num;
                                            if (agency != null && agency.TryGetResourceStockValue(army2.Empire.SimulationObject, resourceName, out num, false) && num >= (float)wantedAmount)
                                            {
                                                return(State.Running);
                                            }
                                            break;
                                        }
                                    }
                                }
                            }
                            if ((pointOfInterest.Interaction.Bits & aiBehaviorTree.AICommander.Empire.Bits) != aiBehaviorTree.AICommander.Empire.Bits)
                            {
                                pointOfInterest.Interaction.Bits |= 1 << orderInteractWith.EmpireIndex;
                            }
                        }
                    }
                    aiBehaviorTree.ErrorCode = 30;
                    this.orderTicket         = null;
                    result = State.Failure;
                }
                else
                {
                    if (this.orderTicket.PostOrderResponse == PostOrderResponse.Processed && service2.TryGetValue(orderInteractWith.TargetGUID, out gameEntity) && gameEntity is PointOfInterest && orderInteractWith.Tags.Contains("Talk") && orderInteractWith.QuestRewards == null)
                    {
                        PointOfInterest pointOfInterest2 = gameEntity as PointOfInterest;
                        Diagnostics.Log("ELCP: Empire {0} AIBehaviorTreeNode_Action_SearchInRuin parley order without quest reward: {1} ", new object[]
                        {
                            aiBehaviorTree.AICommander.Empire.ToString(),
                            pointOfInterest2.WorldPosition
                        });
                        if (pointOfInterest2 != null)
                        {
                            pointOfInterest2.Interaction.Bits |= 1 << orderInteractWith.EmpireIndex;
                        }
                    }
                    this.orderTicket = null;
                    result           = State.Success;
                }
            }
        }
        else
        {
            Army army;
            if (base.GetArmyUnlessLocked(aiBehaviorTree, "$Army", out army) > AIArmyMission.AIArmyMissionErrorCode.None)
            {
                result = State.Failure;
            }
            else
            {
                if (!aiBehaviorTree.Variables.ContainsKey(this.TargetVarName))
                {
                    aiBehaviorTree.LogError("${0} not set", new object[]
                    {
                        this.TargetVarName
                    });
                    return(State.Failure);
                }
                IGameEntity gameEntity2 = aiBehaviorTree.Variables[this.TargetVarName] as IGameEntity;
                if (!(gameEntity2 is IWorldPositionable) || (!(gameEntity2 is PointOfInterest) && !(gameEntity2 is Village)))
                {
                    aiBehaviorTree.ErrorCode = 10;
                    return(State.Failure);
                }
                if (gameEntity2 is Village)
                {
                    Village village = gameEntity2 as Village;
                    Diagnostics.Log("ELCP {0} {1} AIBehaviorTreeNode_Action_SearchInRuin village {2} {3}", new object[]
                    {
                        aiBehaviorTree.AICommander.Empire,
                        army.LocalizedName,
                        village.WorldPosition,
                        this.QuestVillage
                    });
                    PointOfInterest pointOfInterest3 = village.PointOfInterest;
                    if (pointOfInterest3 == null)
                    {
                        return(State.Failure);
                    }
                    if (!this.QuestVillage)
                    {
                        if (village.HasBeenConverted || village.HasBeenPacified || village.IsInEncounter || village.PointOfInterest.PointOfInterestImprovement == null)
                        {
                            return(State.Failure);
                        }
                        if (!aiBehaviorTree.AICommander.Empire.GetAgency <DepartmentOfScience>().CanParley())
                        {
                            return(State.Failure);
                        }
                        if (pointOfInterest3.SimulationObject.Tags.Contains(Village.DissentedVillage))
                        {
                            return(State.Failure);
                        }
                        if ((pointOfInterest3.Interaction.Bits & army.Empire.Bits) != 0)
                        {
                            Diagnostics.Log("fail");
                            return(State.Failure);
                        }
                        QuestMarker questMarker2;
                        if (service.Game.Services.GetService <IQuestManagementService>().TryGetMarkerByGUID(pointOfInterest3.GUID, out questMarker2))
                        {
                            Diagnostics.Log("ELCP: Empire {0} AIBehaviorTreeNode_Action_SearchInRuin Questmarker active", new object[]
                            {
                                aiBehaviorTree.AICommander.Empire.ToString()
                            });
                            return(State.Failure);
                        }
                    }
                }
                Diagnostics.Assert(AIScheduler.Services != null);
                if (service.Game.Services.GetService <IWorldPositionningService>().GetDistance(army.WorldPosition, (gameEntity2 as IWorldPositionable).WorldPosition) != 1)
                {
                    aiBehaviorTree.ErrorCode = 12;
                    result = State.Failure;
                }
                else
                {
                    IEncounterRepositoryService service4 = service.Game.Services.GetService <IEncounterRepositoryService>();
                    if (service4 != null)
                    {
                        IEnumerable <Encounter> enumerable = service4;
                        if (enumerable != null && enumerable.Any((Encounter encounter) => encounter.IsGarrisonInEncounter(army.GUID, false)))
                        {
                            return(State.Running);
                        }
                    }
                    if (gameEntity2 is Village)
                    {
                        Diagnostics.Log("ELCP {0} {1} AIBehaviorTreeNode_Action_SearchInRuin2 village", new object[]
                        {
                            aiBehaviorTree.AICommander.Empire,
                            army.LocalizedName
                        });
                        PointOfInterest   pointOfInterest4   = (gameEntity2 as Village).PointOfInterest;
                        OrderInteractWith orderInteractWith2 = new OrderInteractWith(army.Empire.Index, army.GUID, "ArmyActionParley");
                        orderInteractWith2.WorldPosition = army.WorldPosition;
                        orderInteractWith2.Tags.AddTag("Talk");
                        orderInteractWith2.TargetGUID     = pointOfInterest4.GUID;
                        orderInteractWith2.ArmyActionName = "ArmyActionParley";
                        orderInteractWith2.NumberOfActionPointsToSpend = 0f;
                        aiBehaviorTree.AICommander.Empire.PlayerControllers.AI.PostOrder(orderInteractWith2, out this.orderTicket, null);
                    }
                    else
                    {
                        if (Amplitude.Unity.Framework.Application.Preferences.EnableModdingTools)
                        {
                            Diagnostics.Log("~~~~~ ELCP: {0}/{1} ArmyActionSearch at {2}, {3} {4} ~~~~~", new object[]
                            {
                                army.LocalizedName,
                                army.Empire,
                                (gameEntity2 as PointOfInterest).WorldPosition,
                                ((gameEntity2 as PointOfInterest).Interaction.Bits & army.Empire.Bits) == army.Empire.Bits,
                                (gameEntity2 as PointOfInterest).UntappedDustDeposits
                            });
                        }
                        OrderInteractWith orderInteractWith3 = new OrderInteractWith(army.Empire.Index, army.GUID, "ArmyActionSearch");
                        orderInteractWith3.WorldPosition = army.WorldPosition;
                        orderInteractWith3.Tags.AddTag("Interact");
                        orderInteractWith3.TargetGUID = gameEntity2.GUID;
                        aiBehaviorTree.AICommander.Empire.PlayerControllers.AI.PostOrder(orderInteractWith3, out this.orderTicket, null);
                    }
                    result = State.Running;
                }
            }
        }
        return(result);
    }
コード例 #23
0
    public override void Begin(params object[] parameters)
    {
        base.Begin(parameters);
        bool canceled = false;

        if (parameters.Length >= 1 && parameters[0] is bool)
        {
            canceled = (bool)parameters[0];
        }
        global::PlayerController playerController = base.BattleEncounter.PlayerController;

        if (playerController != null)
        {
            OrderLockEncounterExternalArmies order = new OrderLockEncounterExternalArmies(base.BattleEncounter.EncounterGUID, base.BattleEncounter.ExternalArmies, false);
            playerController.PostOrder(order);
            for (int i = 0; i < base.BattleEncounter.BattleContenders.Count; i++)
            {
                BattleContender battleContender = base.BattleEncounter.BattleContenders[i];
                if (battleContender.DeadParasitesCount > 0)
                {
                    BattleContender enemyContenderWithAbilityFromContender = base.BattleEncounter.GetEnemyContenderWithAbilityFromContender(battleContender, UnitAbility.ReadonlyParasite);
                    if (enemyContenderWithAbilityFromContender != null)
                    {
                        enemyContenderWithAbilityFromContender.UndeadUnitsToCreateCount += battleContender.DeadParasitesCount;
                    }
                }
            }
            for (int j = 0; j < base.BattleEncounter.BattleContenders.Count; j++)
            {
                BattleContender battleContender2 = base.BattleEncounter.BattleContenders[j];
                if (battleContender2.Garrison != null && battleContender2.UndeadUnitsToCreateCount > 0)
                {
                    OrderCreateUndeadUnits order2 = new OrderCreateUndeadUnits(battleContender2.Garrison.Empire.Index, battleContender2.UndeadUnitsToCreateCount, battleContender2.Garrison.GUID, base.BattleEncounter.EncounterGUID);
                    playerController.PostOrder(order2);
                }
            }
            OrderEndEncounter orderEndEncounter = new OrderEndEncounter(base.BattleEncounter.EncounterGUID, canceled);
            IGameService      service           = Services.GetService <IGameService>();
            Diagnostics.Assert(service != null);
            if (ELCPUtilities.UseELCPFortificationPointRuleset)
            {
                Diagnostics.Assert(service != null);
                IEncounterRepositoryService service2 = service.Game.Services.GetService <IEncounterRepositoryService>();
                Diagnostics.Assert(service2 != null);
                Encounter encounter = null;
                if (service2.TryGetValue(base.BattleEncounter.EncounterGUID, out encounter))
                {
                    List <ulong> list = new List <ulong>();
                    foreach (Contender contender in encounter.Contenders)
                    {
                        if (contender.IsTakingPartInBattle)
                        {
                            foreach (EncounterUnit encounterUnit in contender.EncounterUnits)
                            {
                                if (encounterUnit.IsOnBattlefield)
                                {
                                    list.Add(encounterUnit.Unit.GUID);
                                }
                            }
                        }
                    }
                    orderEndEncounter.GUIDsOnBattlefield = list.ToArray();
                }
            }
            if (base.BattleEncounter is BattleCityAssaultEncounter)
            {
                orderEndEncounter.DoNotSubtractActionPoints = (base.BattleEncounter as BattleCityAssaultEncounter).IsCityRipeForTheTaking;
            }
            playerController.PostOrder(orderEndEncounter);
            if (base.BattleEncounter is BattleCityAssaultEncounter && base.BattleEncounter.BattleContenders.Count >= 1)
            {
                BattleCityAssaultEncounter   battleCityAssaultEncounter = base.BattleEncounter as BattleCityAssaultEncounter;
                IGameEntityRepositoryService service3 = service.Game.Services.GetService <IGameEntityRepositoryService>();
                Diagnostics.Assert(service3 != null);
                IGameEntity gameEntity = null;
                City        city       = null;
                if (service3.TryGetValue(battleCityAssaultEncounter.CityGuid, out gameEntity) && gameEntity is City)
                {
                    city = (gameEntity as City);
                }
                bool flag  = false;
                bool flag2 = false;
                for (int k = 0; k < base.BattleEncounter.BattleContenders.Count; k++)
                {
                    BattleContender battleContender3 = base.BattleEncounter.BattleContenders[k];
                    if (battleContender3.IsTakingPartInBattle && !battleContender3.IsDead)
                    {
                        if (battleContender3.Garrison.Empire == city.Empire)
                        {
                            flag = true;
                        }
                        else
                        {
                            flag2 = true;
                        }
                    }
                    else if (!battleContender3.IsTakingPartInBattle && battleContender3.Garrison.GUID == city.GUID && battleContender3.Garrison.UnitsCount > 0)
                    {
                        flag = true;
                    }
                }
                flag |= !flag2;
                OrderCityEncounterEnd order3 = new OrderCityEncounterEnd(base.BattleEncounter.BattleContenders[0].Garrison.Empire.Index, base.BattleEncounter.BattleContenders[0].Garrison.GUID, battleCityAssaultEncounter.CityGuid, flag);
                playerController.PostOrder(order3);
            }
        }
    }
コード例 #24
0
    protected override State Execute(AIBehaviorTree aiBehaviorTree, params object[] parameters)
    {
        if (this.TypeOfDiplomaticRelation == "VillageQuest" && (!(aiBehaviorTree.AICommander.Empire is MajorEmpire) || !aiBehaviorTree.AICommander.Empire.GetAgency <DepartmentOfScience>().CanParley()))
        {
            return(State.Failure);
        }
        if (this.DiplomacyLayer == null && aiBehaviorTree.AICommander.Empire is MajorEmpire)
        {
            AIEntity_Empire entity = aiBehaviorTree.AICommander.AIPlayer.GetEntity <AIEntity_Empire>();
            this.DiplomacyLayer = entity.GetLayer <AILayer_Diplomacy>();
        }
        IGameService service = Services.GetService <IGameService>();

        Diagnostics.Assert(service != null);
        Army army;

        if (base.GetArmyUnlessLocked(aiBehaviorTree, "$Army", out army) > AIArmyMission.AIArmyMissionErrorCode.None)
        {
            return(State.Failure);
        }
        if (!aiBehaviorTree.Variables.ContainsKey(this.TargetListVarName))
        {
            return(State.Failure);
        }
        List <IWorldPositionable> list = aiBehaviorTree.Variables[this.TargetListVarName] as List <IWorldPositionable>;

        if (list == null || list.Count == 0)
        {
            aiBehaviorTree.ErrorCode = 10;
            return(State.Failure);
        }
        List <IWorldPositionable> list2 = null;

        if (this.TypeOfTarget == AIBehaviorTreeNode_Decorator_SelectTarget.TargetType.Army)
        {
            list2 = list.FindAll((IWorldPositionable match) => match is Army);
        }
        else if (this.TypeOfTarget == AIBehaviorTreeNode_Decorator_SelectTarget.TargetType.Ruin)
        {
            list2 = this.Execute_GetRuins(aiBehaviorTree, army, service, list);
        }
        else if (this.TypeOfTarget == AIBehaviorTreeNode_Decorator_SelectTarget.TargetType.Village)
        {
            list2 = this.Execute_GetVillages(aiBehaviorTree, army, service, list);
        }
        else if (this.TypeOfTarget > AIBehaviorTreeNode_Decorator_SelectTarget.TargetType.Village && this.TypeOfTarget < AIBehaviorTreeNode_Decorator_SelectTarget.TargetType.VolcanoformerDevice)
        {
            list2 = this.Execute_GetKaijus(aiBehaviorTree, army, service, list);
        }
        else if (this.TypeOfTarget == AIBehaviorTreeNode_Decorator_SelectTarget.TargetType.VolcanoformerDevice)
        {
            list2 = this.Execute_GetVolcanoformers(aiBehaviorTree, army, service, list);
        }
        else if (this.TypeOfTarget == AIBehaviorTreeNode_Decorator_SelectTarget.TargetType.Fortress)
        {
            list2 = this.Execute_GetFortresses(aiBehaviorTree, army, service, list);
        }
        else if (this.TypeOfTarget == AIBehaviorTreeNode_Decorator_SelectTarget.TargetType.Any)
        {
            list2 = new List <IWorldPositionable>(list);
        }
        if (army.Empire is MinorEmpire || army.Empire is NavalEmpire)
        {
            for (int i = list2.Count - 1; i >= 0; i--)
            {
                Garrison garrison = list2[i] as Garrison;
                if (garrison != null && garrison.Hero != null && garrison.Hero.IsSkillUnlocked("HeroSkillLeaderMap07"))
                {
                    list2.RemoveAt(i);
                }
            }
        }
        IGameEntityRepositoryService service2 = service.Game.Services.GetService <IGameEntityRepositoryService>();
        IWorldPositionningService    service3 = service.Game.Services.GetService <IWorldPositionningService>();
        bool flag = false;

        if (this.TypeOfDiplomaticRelation == "VillageQuest")
        {
            flag = true;
        }
        if (!string.IsNullOrEmpty(this.TypeOfDiplomaticRelationVariableName) && aiBehaviorTree.Variables.ContainsKey(this.TypeOfDiplomaticRelationVariableName))
        {
            this.TypeOfDiplomaticRelation = (aiBehaviorTree.Variables[this.TypeOfDiplomaticRelationVariableName] as string);
        }
        DepartmentOfForeignAffairs departmentOfForeignAffairs = null;
        bool canAttack = false;

        if (this.TypeOfDiplomaticRelation == "Enemy")
        {
            departmentOfForeignAffairs = aiBehaviorTree.AICommander.Empire.GetAgency <DepartmentOfForeignAffairs>();
            canAttack = true;
        }
        else if (this.TypeOfDiplomaticRelation == "DangerForMe")
        {
            departmentOfForeignAffairs = aiBehaviorTree.AICommander.Empire.GetAgency <DepartmentOfForeignAffairs>();
            canAttack = false;
        }
        for (int j = list2.Count - 1; j >= 0; j--)
        {
            if (!AIBehaviorTreeNode_Decorator_SelectTarget.ValidateTarget(army, list2[j] as IGameEntity, departmentOfForeignAffairs, canAttack, service2, service3))
            {
                list2.RemoveAt(j);
            }
            else if (list2[j] is IGarrison && departmentOfForeignAffairs != null && this.DiplomacyLayer != null && (list2[j] as IGarrison).Empire is MajorEmpire && this.DiplomacyLayer.GetPeaceWish((list2[j] as IGarrison).Empire.Index))
            {
                if (!(list2[j] is Army) || !(list2[j] as Army).IsPrivateers)
                {
                    list2.RemoveAt(j);
                }
            }
            else if (flag && list2[j] is Village && !this.ValidQuestVillage(list2[j] as Village, army))
            {
                list2.RemoveAt(j);
            }
        }
        IWorldPositionningService worldPositionService = service.Game.Services.GetService <IWorldPositionningService>();

        if (list2 != null && list2.Count != 0)
        {
            bool flag2;
            if (this.TypeOfTarget == AIBehaviorTreeNode_Decorator_SelectTarget.TargetType.Ruin || this.TypeOfTarget == AIBehaviorTreeNode_Decorator_SelectTarget.TargetType.Fortress)
            {
                flag2 = army.SimulationObject.Tags.Contains("MovementCapacitySail");
            }
            else
            {
                flag2 = army.HasSeafaringUnits();
            }
            Diagnostics.Assert(worldPositionService != null);
            if (!flag2)
            {
                list2.RemoveAll((IWorldPositionable element) => worldPositionService.IsWaterTile(element.WorldPosition));
            }
            if (army.IsSeafaring)
            {
                list2.RemoveAll((IWorldPositionable element) => !worldPositionService.IsWaterTile(element.WorldPosition));
                list2.RemoveAll((IWorldPositionable element) => worldPositionService.IsFrozenWaterTile(element.WorldPosition));
            }
        }
        if (list2 != null && list2.Count != 0)
        {
            if (list2.Count > 1)
            {
                list2.Sort((IWorldPositionable left, IWorldPositionable right) => worldPositionService.GetDistance(left.WorldPosition, army.WorldPosition).CompareTo(worldPositionService.GetDistance(right.WorldPosition, army.WorldPosition)));
            }
            if (aiBehaviorTree.Variables.ContainsKey(this.Output_TargetVarName))
            {
                aiBehaviorTree.Variables[this.Output_TargetVarName] = list2[0];
            }
            else
            {
                aiBehaviorTree.Variables.Add(this.Output_TargetVarName, list2[0]);
            }
        }
        else if (aiBehaviorTree.Variables.ContainsKey(this.Output_TargetVarName))
        {
            aiBehaviorTree.Variables.Remove(this.Output_TargetVarName);
        }
        State result;

        if (this.Inverted)
        {
            if (list2 != null && list2.Count != 0)
            {
                result = State.Failure;
            }
            else
            {
                result = State.Success;
            }
        }
        else if (list2 != null && list2.Count != 0)
        {
            result = State.Success;
        }
        else
        {
            aiBehaviorTree.ErrorCode = 10;
            result = State.Failure;
        }
        return(result);
    }
コード例 #25
0
    private static bool ValidateTarget(Army myArmy, IGameEntity gameEntity, DepartmentOfForeignAffairs departmentOfForeignAffairs, bool canAttack, IGameEntityRepositoryService gameEntityRepositoryService, IWorldPositionningService worldPositionningService)
    {
        if (gameEntity == null)
        {
            return(false);
        }
        if (!gameEntityRepositoryService.Contains(gameEntity.GUID))
        {
            return(false);
        }
        if (departmentOfForeignAffairs != null)
        {
            IGarrison garrison = gameEntity as IGarrison;
            if (gameEntity is Kaiju)
            {
                garrison   = (gameEntity as Kaiju).GetActiveTroops();
                gameEntity = garrison;
            }
            IWorldPositionable worldPositionable = gameEntity as IWorldPositionable;
            Region             region            = worldPositionningService.GetRegion(worldPositionable.WorldPosition);
            if (garrison == null || worldPositionable == null)
            {
                return(false);
            }
            if (canAttack)
            {
                if (!departmentOfForeignAffairs.CanAttack(gameEntity) || garrison.Empire.Index == myArmy.Empire.Index)
                {
                    return(false);
                }
            }
            else if (!departmentOfForeignAffairs.IsEnnemy(garrison.Empire))
            {
                return(false);
            }
            if ((garrison.Empire is MinorEmpire || garrison is Village) && region != null && region.IsRegionColonized() && departmentOfForeignAffairs != null && departmentOfForeignAffairs.IsEnnemy(region.Owner))
            {
                return(false);
            }
        }
        Army army = gameEntity as Army;

        if (army != null)
        {
            if (myArmy.Empire is LesserEmpire && !(army.Empire is MajorEmpire))
            {
                return(false);
            }
            District district = worldPositionningService.GetDistrict(army.WorldPosition);
            if (district != null && district.Type != DistrictType.Exploitation && army.Empire == district.Empire)
            {
                return(false);
            }
            if (!myArmy.HasSeafaringUnits() && army.IsNaval)
            {
                return(false);
            }
        }
        return(true);
    }
コード例 #26
0
ファイル: HeroPool.cs プロジェクト: LeaderEnemyBoss/ELCP
 protected override void Releasing()
 {
     this.GameEntityRepositoryService = null;
     base.Releasing();
 }
コード例 #27
0
    public SimulationObjectWrapper GetTargetSimulationObjectWrapper(QuestBehaviour questBehaviour)
    {
        if (global::GameManager.Preferences.QuestVerboseMode)
        {
            Diagnostics.Log("ELCP: {0} QuestBehaviourPrerequisites.GetTargetSimulationObjectWrapper {1} {2}", new object[]
            {
                questBehaviour.Initiator,
                this.TargetGUID,
                base.Target
            });
        }
        if (base.XmlSerializableTarget == "$Empire")
        {
            this.targetSimulationObjectWrapper = questBehaviour.Initiator;
            return(this.targetSimulationObjectWrapper);
        }
        global::Empire empire;

        if (questBehaviour.TryGetQuestVariableValueByName <global::Empire>(base.Target, out empire) && empire != null)
        {
            this.EmpireIndex = empire.Index;
            return(empire);
        }
        if (this.EmpireIndex >= 0)
        {
            IGameService service = Services.GetService <IGameService>();
            if (service == null || service.Game == null)
            {
                Diagnostics.LogError("Failed to retrieve the game service.");
                return(null);
            }
            global::Game game = service.Game as global::Game;
            if (game == null)
            {
                Diagnostics.LogError("Failed to cast gameService.Game to Game.");
                return(null);
            }
            if (game.Empires[this.EmpireIndex] != null)
            {
                return(game.Empires[this.EmpireIndex]);
            }
        }
        IGameEntity gameEntity;

        if (questBehaviour.TryGetQuestVariableValueByName <IGameEntity>(base.Target, out gameEntity) && gameEntity != null && gameEntity.GUID != GameEntityGUID.Zero && gameEntity is SimulationObjectWrapper)
        {
            this.TargetGUID = gameEntity.GUID;
            this.targetSimulationObjectWrapper = (gameEntity as SimulationObjectWrapper);
            return(this.targetSimulationObjectWrapper);
        }
        if (this.TargetGUID != GameEntityGUID.Zero)
        {
            IGameService service2 = Services.GetService <IGameService>();
            if (service2 == null || service2.Game == null)
            {
                Diagnostics.LogError("Failed to retrieve the game service.");
                return(null);
            }
            global::Game game2 = service2.Game as global::Game;
            if (game2 == null)
            {
                Diagnostics.LogError("Failed to cast gameService.Game to Game.");
                return(null);
            }
            IGameEntityRepositoryService service3 = game2.Services.GetService <IGameEntityRepositoryService>();
            if (service3 == null)
            {
                Diagnostics.LogError("Failed to retrieve the game entity repository service.");
                return(null);
            }
            if (service3.TryGetValue(this.TargetGUID, out gameEntity) && gameEntity != null && gameEntity.GUID != GameEntityGUID.Zero && gameEntity is SimulationObjectWrapper)
            {
                this.TargetGUID = gameEntity.GUID;
                this.targetSimulationObjectWrapper = (gameEntity as SimulationObjectWrapper);
                return(this.targetSimulationObjectWrapper);
            }
        }
        return(null);
    }