private void ReleaseZombieInstanceImplementation(ushort instance, ref ZombieInstance data)
        {
            ZombieInfo info = data.Info;

            if (info != null)
            {
                info.m_zombieAI.ReleaseInstance(instance, ref this.m_instances.m_buffer[(int)instance]);
            }
            data.Unspawn(instance);
            InstanceID id = default(InstanceID);

            id.CitizenInstance = instance;
            Singleton <InstanceManager> .instance.ReleaseInstance(id);

            if (data.m_path != 0u)
            {
                Singleton <PathManager> .instance.ReleasePath(data.m_path);

                data.m_path = 0u;
            }
            if (data.m_zombie != 0u)
            {
                this.m_zombies.m_buffer[(int)((UIntPtr)data.m_zombie)].m_instance = 0;
                data.m_zombie = 0u;
            }
            data.m_flags = ZombieInstance.Flags.None;
            this.m_instances.ReleaseItem(instance);
            this.m_instanceCount = (int)(this.m_instances.ItemCount() - 1u);
        }
 protected override void SimulationStepImpl(int subStep)
 {
     Logger.LogClassAndMethodName(this.GetType().Name, System.Reflection.MethodBase.GetCurrentMethod().Name);
     if (subStep != 0)
     {
         int num  = (int)(Singleton <SimulationManager> .instance.m_currentFrameIndex & 4095u);
         int num2 = num * 256;
         int num3 = (num + 1) * 256 - 1;
         for (int i = num2; i <= num3; i++)
         {
             if ((this.m_zombies.m_buffer[i].m_flags & Zombie.Flags.Created) != Zombie.Flags.None)
             {
                 ZombieInfo zombieInfo = this.m_zombies.m_buffer[i].getZombieInfo((uint)i);
                 if (zombieInfo == null)
                 {
                     this.ReleaseZombie((uint)i);
                 }
                 else
                 {
                     zombieInfo.m_zombieAI.SimulationStep((uint)i, ref this.m_zombies.m_buffer[i]);
                 }
             }
         }
         if (num == 4095)
         {
             this.m_finalOldestOriginalResident = this.m_tempOldestOriginalResident;
             this.m_tempOldestOriginalResident  = 0;
         }
     }
     if (subStep != 0)
     {
         SimulationManager instance         = Singleton <SimulationManager> .instance;
         Vector3           physicsLodRefPos = instance.m_simulationView.m_position + instance.m_simulationView.m_direction * 200f;
         int num7 = (int)(Singleton <SimulationManager> .instance.m_currentFrameIndex & 15u);
         int num8 = num7 * 4096;
         int num9 = (num7 + 1) * 4096 - 1;
         for (int k = num8; k <= num9; k++)
         {
             if ((this.m_instances.m_buffer[k].m_flags & ZombieInstance.Flags.Created) != ZombieInstance.Flags.None)
             {
                 ZombieInfo info = this.m_instances.m_buffer[k].Info;
                 info.m_zombieAI.SimulationStep((ushort)k, ref this.m_instances.m_buffer[k], physicsLodRefPos);
             }
         }
     }
 }
 public static void RenderInstance(RenderManager.CameraInfo cameraInfo, ZombieInfo info, Vector3 position)
 {
     if (info.m_prefabInitialized)
     {
         float maxDistance = Mathf.Min(RenderManager.LevelOfDetailFactor * 800f, info.m_maxRenderDistance + cameraInfo.m_height * 0.5f);
         if (cameraInfo == null || info.m_lodMesh == null || cameraInfo.CheckRenderDistance(position, maxDistance))
         {
             Matrix4x4 matrix = default(Matrix4x4);
             matrix.SetTRS(position, Quaternion.identity, new Vector3(20f, 20f, 20f));
             if (asseteditorDrawMesh == null)
             {
                 asseteditorDrawMesh = new Mesh();
             }
             info.m_skinRenderer.BakeMesh(asseteditorDrawMesh);
             Graphics.DrawMesh(asseteditorDrawMesh, matrix, info.m_skinRenderer.sharedMaterial, LayerMask.NameToLayer("Citizens"));
         }
     }
 }
        public bool CreateZombieInstance(out ushort instanceID, ref Randomizer randomizer, ZombieInfo info, uint zombie)
        {
            ushort newInstanceId;

            if (this.m_instances.CreateItem(out newInstanceId, ref randomizer))
            {
                instanceID = newInstanceId;
                ZombieInstance.Frame frame;
                frame.m_velocity       = Vector3.zero;
                frame.m_position       = Vector3.zero;
                frame.m_rotation       = Quaternion.identity;
                frame.m_underground    = false;
                frame.m_insideBuilding = false;
                frame.m_transition     = false;
                this.m_instances.m_buffer[(int)instanceID].m_flags              = ZombieInstance.Flags.Created;
                this.m_instances.m_buffer[(int)instanceID].Info                 = info;
                this.m_instances.m_buffer[(int)instanceID].m_zombie             = zombie;
                this.m_instances.m_buffer[(int)instanceID].m_frame0             = frame;
                this.m_instances.m_buffer[(int)instanceID].m_frame1             = frame;
                this.m_instances.m_buffer[(int)instanceID].m_frame2             = frame;
                this.m_instances.m_buffer[(int)instanceID].m_frame3             = frame;
                this.m_instances.m_buffer[(int)instanceID].m_targetPos          = Vector3.zero;
                this.m_instances.m_buffer[(int)instanceID].m_targetDir          = Vector2.zero;
                this.m_instances.m_buffer[(int)instanceID].m_sourceBuilding     = 0;
                this.m_instances.m_buffer[(int)instanceID].m_targetBuilding     = 0;
                this.m_instances.m_buffer[(int)instanceID].m_nextGridInstance   = 0;
                this.m_instances.m_buffer[(int)instanceID].m_nextSourceInstance = 0;
                this.m_instances.m_buffer[(int)instanceID].m_nextTargetInstance = 0;
                this.m_instances.m_buffer[(int)instanceID].m_lastFrame          = 0;
                this.m_instances.m_buffer[(int)instanceID].m_pathPositionIndex  = 0;
                this.m_instances.m_buffer[(int)instanceID].m_lastPathOffset     = 0;
                this.m_instances.m_buffer[(int)instanceID].m_waitCounter        = 0;
                this.m_instances.m_buffer[(int)instanceID].m_targetSeed         = 0;
                if (zombie != 0u)
                {
                    this.m_zombies.m_buffer[(int)((UIntPtr)zombie)].m_instance = instanceID;
                }
                Logger.Error("InstanceID:" + instanceID);
                Logger.Error("Buffer:" + this.m_instances.m_buffer[(int)instanceID]);
                info.m_zombieAI.CreateInstance(instanceID, ref this.m_instances.m_buffer[(int)instanceID]);
                this.m_instanceCount = (int)(this.m_instances.ItemCount() - 1u);
                Logger.Log("Zombie Instance created with instance id : " + instanceID);
                return(true);
            }
            instanceID = 0;
            return(false);
        }