Example #1
0
    private void OnSelectKaijuUnlockCB(GameObject obj)
    {
        if (this.empire == null)
        {
            Diagnostics.LogError("Empire is null");
            return;
        }
        IGameService service = Services.GetService <IGameService>();

        if (service == null || service.Game == null)
        {
            Diagnostics.LogError("GameService or GameService.Game is null");
            return;
        }
        IKaijuTechsService service2 = service.Game.Services.GetService <IKaijuTechsService>();

        DepartmentOfScience.ConstructibleElement.State technologyState = service2.GetTechnologyState(this.TechnologyDefinition, this.empire);
        ConstructionQueue constructionQueueForEmpire = service2.GetConstructionQueueForEmpire(this.empire);

        if (constructionQueueForEmpire == null)
        {
            return;
        }
        if (technologyState == DepartmentOfScience.ConstructibleElement.State.Available)
        {
            this.AgeTransform.Enable = false;
            this.QueueResearch();
            this.selectionClient.SendMessage("OnSelectTechnology", this.AgeTransform, SendMessageOptions.RequireReceiver);
        }
        else if (technologyState == DepartmentOfScience.ConstructibleElement.State.InProgress || technologyState == DepartmentOfScience.ConstructibleElement.State.Queued)
        {
            this.AgeTransform.Enable = false;
            Construction construction = constructionQueueForEmpire.Get(this.TechnologyDefinition);
            this.CancelResearch(construction);
            this.selectionClient.SendMessage("OnSelectTechnology", this.AgeTransform, SendMessageOptions.RequireReceiver);
        }
    }