public override void OnEntitySpawn()
        {
            base.OnEntitySpawn();

            if (World.Api.Side == EnumAppSide.Server)
            {
                EntityBehaviorTaskAI taskAi = GetBehavior <EntityBehaviorTaskAI>();

                taskAi.taskManager.ShouldExecuteTask =
                    (task) => tradingWith == null || (task is AiTaskIdle || task is AiTaskSeekEntity || task is AiTaskGotoEntity);

                if (TradeProps != null)
                {
                    RefreshBuyingSellingInventory();
                    WatchedAttributes.SetDouble("lastRefreshTotalDays", World.Calendar.TotalDays - World.Rand.NextDouble() * 6);
                    Inventory.GiveToTrader((int)TradeProps.Money.nextFloat(1f, World.Rand));
                }
                else
                {
                    World.Logger.Warning("Trader TradeProps not set during trader entity spawn. Won't have any items for sale/purchase.");
                }

                Personality = Personalities.GetKeyAtIndex(World.Rand.Next(Personalities.Count));
                (AnimManager as TraderAnimationManager).Personality = this.Personality;
            }
        }
Exemple #2
0
        public override void OnEntityLoaded()
        {
            base.OnEntityLoaded();

            if (Api.Side == EnumAppSide.Server)
            {
                EntityBehaviorTaskAI taskAi = GetBehavior <EntityBehaviorTaskAI>();
                taskAi.taskManager.ShouldExecuteTask =
                    (task) => tradingWith == null || (task is AiTaskIdle || task is AiTaskSeekEntity || task is AiTaskGotoEntity);
            }
        }
Exemple #3
0
        void init()
        {
            if (entity.World.Side == EnumAppSide.Client)
            {
                return;
            }

            EntityBehaviorTaskAI taskAi = entity.GetBehavior <EntityBehaviorTaskAI>();

            taskAi.taskManager.ShouldExecuteTask = (task) => !IsBeingMilked;

            bhmul = entity.GetBehavior <EntityBehaviorMultiply>();
            bhmul.TotalDaysLastBirth = Math.Max(bhmul.TotalDaysLastBirth, entity.World.Calendar.TotalDays);
        }
Exemple #4
0
        void init()
        {
            lastMilkedTotalHours = entity.WatchedAttributes.GetFloat("lastMilkedTotalHours");
            if (entity.World.Side == EnumAppSide.Client)
            {
                return;
            }

            EntityBehaviorTaskAI taskAi = entity.GetBehavior <EntityBehaviorTaskAI>();

            taskAi.TaskManager.ShouldExecuteTask = (task) => !IsBeingMilked;

            // Make sure TotalDaysLastBirth is not a future date (e.g. when exported from an old world and imported into a new world)
            bhmul = entity.GetBehavior <EntityBehaviorMultiply>();
            bhmul.TotalDaysLastBirth = Math.Min(bhmul.TotalDaysLastBirth, entity.World.Calendar.TotalDays);

            lastMilkedTotalHours = Math.Min(lastMilkedTotalHours, entity.World.Calendar.TotalHours);
        }