コード例 #1
0
 public static void SubmitDeathClaim(byte districtNo, DeathClaim claim)
 {
     districts[districtNo].Add(claim);
     claims[claim.buildingID] = claim;
     registeredBuildings[claim.buildingID]         = true;
     registeredBuildingsDistrict[claim.buildingID] = districtNo;
 }
コード例 #2
0
 public static void RecallDeathClaim(byte districtNo, DeathClaim claim)
 {
     districts[districtNo].FindAndDelete(claim);
     claims[claim.buildingID] = null;
     registeredBuildings[claim.buildingID]         = false;
     registeredBuildingsDistrict[claim.buildingID] = 0;
 }
コード例 #3
0
ファイル: DeathList.cs プロジェクト: gawrbage/SuperHearseAI
        public void FindAndDelete(DeathClaim claim)
        {
            if (count == 0)
            {
                return;             //Possibly could be removed for optimization
            }
            if (claim == head.data)
            {
                DeleteHead(); return;
            }
            if (claim == tail.data)
            {
                DeleteTail(); return;
            }

            Node cursor     = head;
            Node prevCursor = null;

            while (cursor.data != claim)
            {
                prevCursor = cursor;
                cursor     = cursor.next;
                if (cursor == null)
                {
                    return;
                }
            }
            prevCursor.next = null;        //set the target to null
            cursor          = cursor.next; //move the cursor forward
            prevCursor.next = cursor;      //set the prevcursor next to the cursor

            count--;
        }
コード例 #4
0
ファイル: DeathList.cs プロジェクト: gawrbage/SuperHearseAI
        private DeathClaim[] GetArray()
        {
            DeathClaim[] arr    = new DeathClaim[count];
            Node         cursor = head;

            for (int i = 0; i < count; i++)
            {
                arr[i] = cursor.data;
                cursor = cursor.next;
            }
            return(arr);
        }
コード例 #5
0
ファイル: DeathList.cs プロジェクト: gawrbage/SuperHearseAI
        public void Add(DeathClaim claim)
        {
            count++;
            Node n = new Node(claim);

            if (head == null)
            {
                head = n;
                tail = n;
                return;
            }

            tail.next = n;
            tail      = n;
            return;
        }
コード例 #6
0
        public override void SimulationStep(uint citizenID, ref Citizen data)
        {
            base.SimulationStep(citizenID, ref data);

            /* TODO:
             * remove lock statements as they may not be useful
             * also refactor code
             */

            switch (data.CurrentLocation)
            {
            case Citizen.Location.Home:
                if (data.m_homeBuilding == 0)
                {
                    return;
                }
                break;

            case Citizen.Location.Moving:
                if (data.m_vehicle == 0)
                {
                    return;
                }
                break;

            case Citizen.Location.Visit:
                if (data.m_visitBuilding == 0)
                {
                    return;
                }
                break;

            case Citizen.Location.Work:
                if (data.m_workBuilding == 0)
                {
                    return;
                }
                break;

            default: return;
            }

            ushort citizenBuilding = 0;

            switch (data.CurrentLocation)
            {
            case Citizen.Location.Home:
                citizenBuilding = data.m_homeBuilding;
                break;

            case Citizen.Location.Visit:
                citizenBuilding = data.m_visitBuilding;
                break;

            case Citizen.Location.Work:
                citizenBuilding = data.m_workBuilding;
                break;

            default: break;
            }

            Vector3 p = Singleton <BuildingManager> .instance.m_buildings.m_buffer[citizenBuilding].m_position;
            byte    currentDistrict = Singleton <DistrictManager> .instance.GetDistrict(p);

            if (data.Dead && (DeathRegistry.IsRegistered(citizenBuilding) == false))
            {
                DeathRegistry.claims[citizenBuilding] = new DeathClaim();
                DeathClaim claim = DeathRegistry.claims[citizenBuilding];
                claim.buildingID = citizenBuilding;
                claim.citizenID  = citizenID;
                claim.pos        = p;
                claim.location   = data.CurrentLocation;

                //Debug.Log("Died At : " + Singleton<BuildingManager>.instance.m_buildings.m_buffer[citizenBuilding].Info.name);

                DeathRegistry.SubmitDeathClaim(currentDistrict, claim);

                return;
            }

            if (data.Dead && DeathRegistry.IsRegistered(citizenBuilding) && DeathRegistry.GetBuildingDistrict(citizenBuilding) != currentDistrict)
            {
                DeathClaim claim = DeathRegistry.claims[citizenBuilding];
                if (!claim.vehicleArriving)
                {
                    DeathRegistry.RecallDeathClaim(DeathRegistry.GetBuildingDistrict(claim.buildingID), claim);

                    DeathRegistry.claims[citizenBuilding] = new DeathClaim();
                    claim            = DeathRegistry.claims[citizenBuilding];
                    claim.buildingID = citizenBuilding;
                    claim.citizenID  = citizenID;
                    claim.pos        = p;
                    claim.location   = data.CurrentLocation;

                    DeathRegistry.SubmitDeathClaim(currentDistrict, claim);

                    return;
                }
            }
        }
コード例 #7
0
 public static void RestClaim(DeathClaim claim)
 {
     registeredBuildings[claim.buildingID]         = false;
     registeredBuildingsDistrict[claim.buildingID] = 0;
     claims[claim.buildingID] = null;
 }
コード例 #8
0
ファイル: DeathList.cs プロジェクト: gawrbage/SuperHearseAI
 internal Node(DeathClaim claim, Node node)
 {
     data = claim;
     next = node;
 }
コード例 #9
0
ファイル: DeathList.cs プロジェクト: gawrbage/SuperHearseAI
 internal Node(DeathClaim claim)
 {
     data = claim;
 }