示例#1
0
        public Actor Spawn(ActorType actorType)
        {
            Stack<GameObject> pool = poolDictionary[actorType];
            if( pool.Count == 0 )
            {
                Debug.Log("empty pool"+actorType);
                return null;
            }
            GameObject spawn = pool.Pop();
            spawn.transform.parent = null;
            Actor actor = spawn.GetComponent<Actor>();
            Bounds bounds = World.Instance.GetLiveableArea(actor.liveableArea);
            float xPos = bounds.center.x;
            float yPos = Random.Range(bounds.min.y, bounds.max.y);
            float zPos = Random.Range(bounds.min.z, bounds.max.z);
            Vector3 startPos = new Vector3(xPos, yPos, zPos);
            Vector3 midPos = startPos;
            midPos.z = 0;
            actor.transform.position = startPos;
            string actorTypeName = actorType.ToString();
            if( actorTypeName.StartsWith("FISH"))
            {
                actor.transform.LookAt(midPos);
            }
            spawn.SetActive(true);

            actor.AfterSpawn();

            return actor;
        }
示例#2
0
        public ActorBehaviour SpawnActor(ActorType actorType, Vector2Int position, bool isBoss = false)
        {
            ActorBehaviour instantiatedActor = _actorBehaviourFactory.Create();

            instantiatedActor.name = actorType.ToString();
            ActorData actorData = instantiatedActor.ActorData;

            actorData.ActorType = actorType;
            actorData.IsBoss    = isBoss;

            ActorDefinition actorDefinition = _gameConfig.ActorConfig.GetDefinition(actorType);

            instantiatedActor.GetComponent <SpriteRenderer>().sprite = actorDefinition.Sprite;
            actorData.WeaponWeld      = _rng.Choice(actorDefinition.WeaponPool);
            actorData.SwordsFromSkill = actorDefinition.SwordsFromSkill;
            actorData.VisionRayLength = actorDefinition.VisionRayLength;
            actorData.EnergyGain      = actorDefinition.EnergyGain;
            actorData.Team            = actorDefinition.Team;
            actorData.MaxHealth       = actorDefinition.MaxHealth;
            actorData.Health          = actorDefinition.MaxHealth;
            actorData.Accuracy        = actorDefinition.Accuracy;
            actorData.XpGiven         = actorDefinition.XpGiven;
            actorData.Level           = actorDefinition.InitialLevel;
            actorData.Traits          = actorDefinition.InitialTraits.ToArray().ToList();
            actorData.AiTraits        = actorDefinition.AiTraits.ToArray().ToList();

            Vector2Int freePosition = GetPositionToPlaceActor(position);

            actorData.LogicalPosition = freePosition;
            instantiatedActor.RefreshWorldPosition();
            _gameContext.Actors.Add(instantiatedActor);
            instantiatedActor.gameObject.SetActive(true);
            return(instantiatedActor);
        }
        public ActorType GetActorType(Actor actor)
        {
            ActorType type      = ActorType.Other;
            UnitSpawn unitSpawn = actor.GetComponent <UnitSpawn>();

            if (unitSpawn as AIAircraftSpawn != null)
            {
                type = ActorType.Plane;
            }
            if (unitSpawn as AISeaUnitSpawn != null)
            {
                type = ActorType.Boat;
            }
            if (unitSpawn as AICarrierSpawn != null)
            {
                type = ActorType.Carrier;
            }
            if (unitSpawn as AIDroneCarrierSpawn != null)
            {
                type = ActorType.DroneCarrier;
            }
            if (unitSpawn as GroundUnitSpawn != null)
            {
                type = ActorType.Tank;
            }
            if (unitSpawn as ArtilleryUnitSpawn != null)
            {
                type = ActorType.Artillery;
            }
            Debug.Log(actor.name + " is a " + type.ToString());
            return(type);
        }
示例#4
0
 public override void AsText(StringBuilder b, int pad)
 {
     b.Append(' ', pad);
     b.AppendLine("ACDCreateActorMessage:");
     b.Append(' ', pad++);
     b.AppendLine("{");
     b.Append(' ', pad); b.AppendLine("ActorID: 0x" + DynamicID.ToString("X8") + " (" + DynamicID + ")");
     b.Append(' ', pad); b.AppendLine("ActorSNOId: 0x" + ActorSNOId.ToString("X8") + "  (" + ActorSNOId + ")");
     b.Append(' ', pad); b.AppendLine("ActorType: 0x" + ActorType.ToString() + "  (" + (int)ActorType + ")");
     b.Append(' ', pad); b.AppendLine("Field2: 0x" + Field2.ToString("X8") + " (" + Field2 + ")");
     b.Append(' ', pad); b.AppendLine("Field3: 0x" + Field3.ToString("X8") + " (" + Field3 + ")");
     b.Append(' ', --pad);
     b.AppendLine("}");
 }
示例#5
0
 public override string ToString()
 {
     return(String.Format("SnoID[{0}] ActorType[{1}] EntryType[{2}] Name[{3}]", SnoId, ActorType.ToString(), EntryType.ToString(), InternalName));
 }
        public static void OpenActorSelectMenu(Building_SacrificialAltar altar, ActorType actorType)
        {
            ///
            /// Error Handling
            ///
            if (altar == null)
            {
                Cthulhu.Utility.ErrorReport("Altar Null Exception");
                return;
            }
            if (altar.Map == null)
            {
                Cthulhu.Utility.ErrorReport("Map Null Exception");
            }
            if (altar.Map.mapPawns == null)
            {
                Cthulhu.Utility.ErrorReport("mapPawns Null Exception");
                return;
            }
            if (altar.Map.mapPawns.FreeColonistsSpawned == null)
            {
                Cthulhu.Utility.ErrorReport("FreeColonistsSpawned Null Exception");
                return;
            }
            //if (altar.Map.mapPawns.FreeColonistsSpawnedCount <= 0)
            //{
            //    Cthulhu.Utility.ErrorReport("Colonist Count Less Than or Equal To 0 Exception");
            //    return;
            //}

            ///
            /// Get Actor List
            ///

            List <Pawn>   actorList = new List <Pawn>();
            StringBuilder s         = new StringBuilder();

            switch (actorType)
            {
            case ActorType.executioner:
            case ActorType.offerer:
                // Cycle through candidates
                foreach (Pawn candidate in altar.Map.mapPawns.FreeColonistsSpawned)
                {
                    if (!CultUtility.IsCultistAvailable(candidate))
                    {
                        continue;
                    }

                    // Executioners must be able to use tool and move.
                    if (candidate.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation) &&
                        candidate.health.capacities.CapableOf(PawnCapacityDefOf.Moving))
                    {
                        // Add the actors.
                        actorList.Add(candidate);
                        Cthulhu.Utility.DebugReport("Actor List :: Added " + candidate.Name);
                    }
                }
                Cthulhu.Utility.DebugReport(s.ToString());
                break;

            case ActorType.preacher:
                // Cycle through candidates
                foreach (Pawn candidate in altar.Map.mapPawns.FreeColonistsSpawned)
                {
                    if (!CultUtility.IsCultistAvailable(candidate))
                    {
                        continue;
                    }

                    // Preachers must be able to move and talk.
                    if (candidate.health.capacities.CapableOf(PawnCapacityDefOf.Moving) &&
                        candidate.health.capacities.CapableOf(PawnCapacityDefOf.Talking))
                    {
                        // Add the actors.
                        actorList.Add(candidate);
                        Cthulhu.Utility.DebugReport("Actor List :: Added " + candidate.Name);
                    }
                }
                Cthulhu.Utility.DebugReport(s.ToString());
                break;

            case ActorType.prisoner:
                ///
                /// ERROR HANDLING
                ///

                if (altar.Map.mapPawns.PrisonersOfColonySpawned == null)
                {
                    Messages.Message("No prisoners available.", MessageTypeDefOf.RejectInput);
                    return;
                }
                if (altar.Map.mapPawns.PrisonersOfColonySpawnedCount <= 0)
                {
                    Messages.Message("No prisoners available.", MessageTypeDefOf.RejectInput);
                    return;
                }


                /// Cycle through possible candidates in the map's prisoner list
                foreach (Pawn candidate in altar.Map.mapPawns.PrisonersOfColonySpawned)
                {
                    if (!Cthulhu.Utility.IsActorAvailable(candidate, true))
                    {
                        continue;
                    }
                    actorList.Add(candidate);
                }
                break;

            case ActorType.animalSacrifice:
                ///
                /// ERROR HANDLING
                ///

                if (altar.Map.mapPawns.AllPawnsSpawned == null)
                {
                    Messages.Message("No " + actorType.ToString() + "s available.", MessageTypeDefOf.RejectInput);
                    return;
                }
                if (altar.Map.mapPawns.AllPawnsSpawnedCount <= 0)
                {
                    Messages.Message("No " + actorType.ToString() + "s available.", MessageTypeDefOf.RejectInput);
                    return;
                }

                /// Cycle through possible candidates in the player's owned animals list.
                foreach (Pawn candidate in altar.Map.mapPawns.AllPawnsSpawned)
                {
                    if (!Cthulhu.Utility.IsActorAvailable(candidate, true))
                    {
                        continue;
                    }
                    if (candidate.Faction != Faction.OfPlayer)
                    {
                        continue;
                    }
                    if (candidate.RaceProps == null)
                    {
                        continue;
                    }
                    if (!candidate.RaceProps.Animal)
                    {
                        continue;
                    }
                    actorList.Add(candidate);
                }
                break;
            }

            /// Let the player know there are no prisoners available.
            if (actorList != null)
            {
                if (actorList.Count <= 0)
                {
                    Messages.Message("No " + actorType.ToString() + "s available.", MessageTypeDefOf.RejectInput);
                    return;
                }
            }

            ///
            /// Create float menus
            ///

            //There must always be a none.
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            list.Add(new FloatMenuOption("(" + "NoneLower".Translate() + ")", delegate
            {
                altar.tempExecutioner = null;
            }, MenuOptionPriority.Default, null, null, 0f, null));

            foreach (Pawn actor in actorList)
            {
                Action action;
                Pawn   localCol = actor;
                action = delegate
                {
                    switch (actorType)
                    {
                    case ActorType.executioner:
                        MapComponent_SacrificeTracker.Get(altar.Map).lastUsedAltar = altar;
                        altar.tempExecutioner = localCol;
                        break;

                    case ActorType.preacher:
                        altar.tempPreacher = localCol;
                        break;

                    case ActorType.offerer:
                        MapComponent_SacrificeTracker.Get(altar.Map).lastUsedAltar = altar;
                        altar.tempOfferer = localCol;
                        break;

                    case ActorType.prisoner:
                        MapComponent_SacrificeTracker.Get(altar.Map).lastUsedAltar     = altar;
                        MapComponent_SacrificeTracker.Get(altar.Map).lastSacrificeType = CultUtility.SacrificeType.human;
                        altar.tempSacrifice = localCol;
                        break;

                    case ActorType.animalSacrifice:
                        MapComponent_SacrificeTracker.Get(altar.Map).lastUsedAltar     = altar;
                        MapComponent_SacrificeTracker.Get(altar.Map).lastSacrificeType = CultUtility.SacrificeType.animal;
                        altar.tempSacrifice = localCol;
                        break;
                    }
                };
                list.Add(new FloatMenuOption(localCol.LabelShort, action, MenuOptionPriority.Default, null, null, 0f, null));
            }

            Find.WindowStack.Add(new FloatMenu(list));
        }
示例#7
0
 void Awake()
 {
     OnConstruct(actor.ToString());
     dialogContainer = new List <GameObject>();
 }
示例#8
0
 public static ActorSingleton shared(ActorType type)
 {
     return(shared(type.ToString()));
 }