Example #1
0
        public void SortObjectives()
        {
            ForcedOrder?.GetPriority();

            AIObjective orderWithHighestPriority = null;
            float       highestPriority          = 0;

            foreach (var currentOrder in CurrentOrders)
            {
                var orderObjective = currentOrder.Objective;
                if (orderObjective == null)
                {
                    continue;
                }
                orderObjective.GetPriority();
                if (orderWithHighestPriority == null || orderObjective.Priority > highestPriority)
                {
                    orderWithHighestPriority = orderObjective;
                    highestPriority          = orderObjective.Priority;
                }
            }
#if SERVER
            if (orderWithHighestPriority != null && orderWithHighestPriority != currentOrder)
            {
                GameMain.NetworkMember.CreateEntityEvent(character, new object[] { NetEntityEvent.Type.ObjectiveManagerOrderState });
            }
#endif
            CurrentOrder = orderWithHighestPriority;

            for (int i = Objectives.Count - 1; i >= 0; i--)
            {
                Objectives[i].GetPriority();
            }
            if (Objectives.Any())
            {
                Objectives.Sort((x, y) => y.Priority.CompareTo(x.Priority));
            }

            GetCurrentObjective()?.SortSubObjectives();
        }