コード例 #1
0
        public static void OnUpdate()
        {
            if (ServerManager.ColonyTracker != null)
            {
                foreach (var colony in ServerManager.ColonyTracker.ColoniesByID.Values)
                {
                    var cs = ColonyState.GetColonyState(colony);
                    EvaluateSettlers(cs);

                    if (cs.Difficulty.Name != GameDifficulty.Normal.Name)
                    {
                        EvaluateLaborers(cs);
                        EvaluateBeds(cs);
                        UpdateFoodUse(cs);
                    }

                    UpdateMagicItemms(cs);

                    colony.SendCommonData();

                    if (_updateTime < Time.SecondsLastFrame && colony.OwnerIsOnline())
                    {
                        NPCBase lastNPC = null;

                        foreach (var follower in colony.Followers)
                        {
                            if (TimeCycle.IsDay)
                            {
                                if (lastNPC == null ||
                                    UnityEngine.Vector3.Distance(lastNPC.Position.Vector, follower.Position.Vector) > 15 &&
                                    Random.NextBool())
                                {
                                    lastNPC = follower;
                                    AudioManager.SendAudio(follower.Position.Vector, GameLoader.NAMESPACE + ".TalkingAudio");
                                }
                            }
                        }
                    }
                }
            }


            if (_updateTime < Time.SecondsLastFrame && TimeCycle.IsDay)
            {
                _updateTime = Time.SecondsLastFrame + _UPDATE_TIME;
            }
        }
コード例 #2
0
        public static void OnUpdate()
        {
            if (ServerManager.ColonyTracker != null)
            {
                foreach (var colony in ServerManager.ColonyTracker.ColoniesByID.Values)
                {
                    var cs = ColonyState.GetColonyState(colony);
                    EvaluateSettlers(cs);

                    if (cs.Difficulty.Name != GameDifficulty.Normal.Name)
                    {
                        EvaluateLaborers(cs);
                        EvaluateBeds(cs);
                        UpdateFoodUse(cs);
                    }

                    UpdateMagicItemms(cs);

                    colony.SendCommonData();

                    if (_updateTime < Time.SecondsLastFrame && colony.OwnerIsOnline())
                    {
                        NPCBase lastNPC = null;

                        foreach (var follower in colony.Followers)
                        {
                            if (TimeCycle.IsDay)
                            {
                                if (lastNPC == null ||
                                    UnityEngine.Vector3.Distance(lastNPC.Position.Vector, follower.Position.Vector) > 15 &&
                                    Random.NextBool())
                                {
                                    lastNPC = follower;
                                    AudioManager.SendAudio(follower.Position.Vector, GameLoader.NAMESPACE + ".TalkingAudio");
                                }
                            }
                        }
                    }

                    if (cs.ColonyRef.FollowerCount > 10)
                    {
                        float foodConsumedPerSecondPerColonist = (cs.FoodPerHour * TimeCycle.GameTimeScale) / 3600;
                        float secondsTick   = (float)Time.SecondsLastFrame;
                        float foodToConsume = foodConsumedPerSecondPerColonist * colony.FollowerCount * secondsTick;
                        float diff          = Math.Min(foodToConsume, _settlersBuffer);
                        foodToConsume   -= diff;
                        _settlersBuffer -= diff;

                        if (foodToConsume > 0.0001f)
                        {
                            colony.Stockpile.TryRemoveFood(ref _settlersBuffer, foodToConsume);
                        }
                    }
                }
            }


            if (_updateTime < Time.SecondsLastFrame && TimeCycle.IsDay)
            {
                _updateTime = Time.SecondsLastFrame + _UPDATE_TIME;
            }
        }