Example #1
0
        void CreateInitialAI(bool loaded)
        {
            if (EntitySystemWorld.Instance.IsEditor())
            {
                return;
            }
            if (loaded && EntitySystemWorld.Instance.SerializationMode == SerializationModes.World)
            {
                return;
            }

            if (Intellect != null)
            {
                return;
            }

            AIType initAI = InitialAI;

            if (initAI == null)
            {
                initAI = Type.InitialAI;
            }

            if (initAI == null)
            {
                return;
            }

            if (EntitySystemWorld.Instance.IsDedicatedServer())
            {
                if (initAI.NetworkType == EntityNetworkTypes.ClientOnly)
                {
                    return;
                }
            }
            if (EntitySystemWorld.Instance.IsClientOnly())
            {
                if (initAI.NetworkType == EntityNetworkTypes.ServerOnly)
                {
                    return;
                }
                if (initAI.NetworkType == EntityNetworkTypes.Synchronized)
                {
                    return;
                }
            }

            //create intellect
            Intellect i = (Intellect)Entities.Instance.Create(initAI, World.Instance);

            i.Faction          = InitialFaction;
            i.ControlledObject = this;
            i.PostCreate();
            SetIntellect(i, true);
        }