public override bool Create()
        {
            try
            {
                Vector3 hunterspawnPos = this.SpawnPosition.AroundPosition(35.0f).ToGround();
                this.Hunter = new Ped(_huntersModels.GetRandomElement(true), hunterspawnPos, MathHelper.GetRandomSingle(0.0f, 359.0f));

                Vector3 animspawnPos = this.Hunter.Position.AroundPosition(27.5f).ToGround();
                this.Animal = new Ped(_animalsModels.GetRandomElement(true), animspawnPos, 0.0f);

                if (this.Animal.Exists())
                {
                    this.Animal.Health = 1250;
                }
                if (this.Hunter.Exists())
                {
                    this.Hunter.Inventory.GiveNewWeapon(_hunterWeapons.GetRandomElement(true), 9999, true);
                }

                SpawnedEntities.Add(this.Hunter);
                SpawnedEntities.Add(this.Animal);

                return(base.Create());
            }
            catch (System.Exception e)
            {
                Logger.LogException(this.GetType().Name, e);
                return(false);
            }
        }
Beispiel #2
0
        private IEnumerator Spawn()
        {
            yield return(new WaitForSeconds(Random.Range(_spawnDelayRange.x, _spawnDelayRange.y)));

            while (true)
            {
                var go = Instantiate(_object[Random.Range(0, 4)], transform.position, transform.rotation, _parent);
                SpawnedEntities.AddShip(go.GetComponent <ISpaceship>());
                yield return(new WaitForSeconds(Random.Range(_spawnPeriodRange.x, _spawnPeriodRange.y)));
            }
        }
Beispiel #3
0
 public void UpdateEconomy(float dt)
 {
     StoreCapacity = new Attr();
     foreach (var building in Buildings)
     {
         building.Update(dt, this);
         StoreCapacity += building.type.storage;
     }
     if (SpawnedEntities.Count > 0)
     {
         Entities.AddRange(SpawnedEntities);
         SpawnedEntities.RemoveAll(e => true);
         UpdateEntityDensity();
     }
     Beds            = Buildings.Sum(e => e.type.beds);
     WorkforceDemand = Buildings.Sum(e => e.type.workforce);
     Store          += -dt * StorageSurplusDecay * (Store + -1 * StoreCapacity).ClampToPositive();
 }
Beispiel #4
0
    public override void ForceSpawn()
    {
        var attributes = new NeedsAttributes();

        attributes.Randomize();

        attributes.Model = AllowedMeshes[Main.Instance.Rand.Next(AllowedMeshes.Length)];
        var model = attributes.GetModel();

        var entity = Instantiate(model, GetNextSpawnLocation(), Quaternion.Euler(ForcedRotation));

        var lostItem = entity.GetComponent <LostItemEntity>();

        lostItem.Attributes = attributes;
        lostItem.ApplyAttributesToMaterial();

        lostItem.DestroyCallback += OnSpawnedDestroyed;
        lostItem.tag              = "Item";

        SpawnedEntities.Add(entity);
    }
Beispiel #5
0
    public override void ForceSpawn()
    {
        var entity = Instantiate(PatronEntity, GetNextSpawnLocation(), Quaternion.Euler(ForcedRotation));

        entity.transform.position = transform.position;
        entity.enabled            = true;

        var spawnedEntity = entity.GetComponent <SpawnedEntity>();

        spawnedEntity.DestroyCallback += OnSpawnedDestroyed;

        var patrol = spawnedEntity.gameObject.AddComponent <Patrol>();

        patrol.poi                = POIS;
        patrol.endPoint           = EndPOI;
        patrol.hintText           = spawnedEntity.GetComponentInChildren <TextMeshPro>();
        patrol.mongus             = spawnedEntity.GetComponentInChildren <MeshCollider>().transform;
        patrol.defaultHintMessage = DefaultHintText;
        patrol.HintWaitSeconds    = HintWaitSeconds;

        SpawnedEntities.Add(entity);
    }
        public override bool Create()
        {
            try
            {
                Ped[] possiblePedsNearInWorld = World.GetAllPeds().Where(x => !x.IsInAnyVehicle(false) && x.IsAlive && x.IsHuman && !x.IsPersistent && Vector3.Distance(x.Position, Game.LocalPlayer.Character.Position) < 120.0f).ToArray();
                possiblePedsNearInWorld.Shuffle();
                Ped = possiblePedsNearInWorld.FirstOrDefault();

                if (Ped == null || !Ped.Exists())
                {
                    Logger.LogTrivial(this.GetType().Name, " Couldn't find any near ped. Aborting event...");
                    return(false);
                }
                Ped.MakePersistent();
                SpawnedEntities.Add(Ped);

                return(base.Create());
            }
            catch (System.Exception e)
            {
                Logger.LogException(this.GetType().Name, e);
                return(false);
            }
        }
 protected virtual void DestroyDrop()
 {
     Destroy(gameObject);
     SpawnedEntities.RemoveDrop(this);
 }
 protected virtual void Start()
 {
     _dropController.Init(this);
     SpawnedEntities.AddDrop(this);
     DestroyDropAfter(_lifeTime);
 }
Beispiel #9
0
 public void AddEntity(EntityType type, Vector3 pos)
 {
     SpawnedEntities.Add(new Entity {
         Type = type, Pos = pos
     });
 }
Beispiel #10
0
        private void PlayerSpawn()
        {
            var go = Instantiate(_playerPrefab, _playerParent);

            SpawnedEntities.AddShip(go.GetComponent <ISpaceship>());
        }