Exemplo n.º 1
0
 public static void Postfix(SleepChore.States __instance)
 {
     if (ModSettings.Instance.ShareBeds)
     {
         __instance.success.Exit(delegate(SleepChore.StatesInstance smi)
         {
             var minion = smi.sm.sleeper.Get(smi).GetComponent <MinionIdentity>();
             if (minion == null)
             {
                 return;
             }
             Ownables ownables = minion.GetSoleOwner();
             if (ownables == null)
             {
                 return;
             }
             AssignableSlotInstance slot = ownables.GetSlot(Db.Get().AssignableSlots.Bed);
             if (slot == null)
             {
                 return;
             }
             slot.Unassign(false);
         });
     }
 }
 public override void Assign(IAssignableIdentity new_assignee)
 {
     if (new_assignee != assignee)
     {
         if (base.slot != null && new_assignee is MinionIdentity)
         {
             new_assignee = (new_assignee as MinionIdentity).assignableProxy.Get();
         }
         if (base.slot != null && new_assignee is StoredMinionIdentity)
         {
             new_assignee = (new_assignee as StoredMinionIdentity).assignableProxy.Get();
         }
         if (new_assignee is MinionAssignablesProxy)
         {
             Ownables soleOwner          = new_assignee.GetSoleOwner();
             Ownables component          = soleOwner.GetComponent <Ownables>();
             AssignableSlotInstance slot = component.GetSlot(base.slot);
             if (slot != null)
             {
                 Assignable assignable = slot.assignable;
                 if ((Object)assignable != (Object)null)
                 {
                     assignable.Unassign();
                 }
             }
         }
         base.Assign(new_assignee);
     }
 }
Exemplo n.º 3
0
 public static void Postfix(EatChore.States __instance)
 {
     if (ModSettings.Instance.ShareTables)
     {
         __instance.eatatmessstation.Exit(delegate(EatChore.StatesInstance smi)
         {
             var minion = smi.sm.eater.Get(smi).GetComponent <MinionIdentity>();
             if (minion == null)
             {
                 return;
             }
             Ownables ownables = minion.GetSoleOwner();
             if (ownables == null)
             {
                 return;
             }
             AssignableSlotInstance slot = ownables.GetSlot(Db.Get().AssignableSlots.MessStation);
             if (slot == null)
             {
                 return;
             }
             slot.Unassign(true);
         });
     }
 }
Exemplo n.º 4
0
        public void UnassignClinic()
        {
            Ownables       soleOwner = base.sm.masterTarget.Get(base.smi).GetComponent <MinionIdentity>().GetSoleOwner();
            AssignableSlot clinic    = Db.Get().AssignableSlots.Clinic;

            soleOwner.GetSlot(clinic)?.Unassign(true);
        }
Exemplo n.º 5
0
 public virtual void Unassign()
 {
     if (assignee != null)
     {
         GetComponent <KPrefabID>().RemoveTag(GameTags.Assigned);
         if (slot != null)
         {
             Ownables soleOwner = assignee.GetSoleOwner();
             if ((bool)soleOwner)
             {
                 soleOwner.GetSlot(slot)?.Unassign(true);
                 Equipment component = soleOwner.GetComponent <Equipment>();
                 if ((UnityEngine.Object)component != (UnityEngine.Object)null)
                 {
                     component.GetSlot(slot)?.Unassign(true);
                 }
             }
         }
         assignee = null;
         if (canBePublic)
         {
             Assign(Game.Instance.assignmentManager.assignment_groups["public"]);
         }
         assignee_identityRef.Set(null);
         assignee_groupID = string.Empty;
         if (this.OnAssign != null)
         {
             this.OnAssign(null);
         }
         Trigger(684616645, null);
     }
 }
    public void FindAvailableMedicalBed(Navigator navigator)
    {
        Clinic                 clinic    = null;
        AssignableSlot         clinic2   = Db.Get().AssignableSlots.Clinic;
        Ownables               soleOwner = gameObject.GetComponent <MinionIdentity>().GetSoleOwner();
        AssignableSlotInstance slot      = soleOwner.GetSlot(clinic2);

        if ((UnityEngine.Object)slot.assignable == (UnityEngine.Object)null)
        {
            Assignable assignable = soleOwner.AutoAssignSlot(clinic2);
            if ((UnityEngine.Object)assignable != (UnityEngine.Object)null)
            {
                clinic = assignable.GetComponent <Clinic>();
            }
        }
        else
        {
            clinic = slot.assignable.GetComponent <Clinic>();
        }
        if ((UnityEngine.Object)clinic != (UnityEngine.Object)null && navigator.CanReach(clinic))
        {
            base.smi.sm.clinic.Set(clinic.gameObject, base.smi);
            base.smi.GoTo(base.smi.sm.incapacitation_root.rescue.waitingForPickup);
        }
    }
Exemplo n.º 7
0
        public void AutoAssignClinic()
        {
            Ownables               soleOwner = base.sm.masterTarget.Get(base.smi).GetComponent <MinionIdentity>().GetSoleOwner();
            AssignableSlot         clinic    = Db.Get().AssignableSlots.Clinic;
            AssignableSlotInstance slot      = soleOwner.GetSlot(clinic);

            if (slot != null && !((Object)slot.assignable != (Object)null))
            {
                soleOwner.AutoAssignSlot(clinic);
            }
        }
Exemplo n.º 8
0
            public static void AutoAssignClinic(WoundMonitor.Instance smi)
            {
                Ownables               component = smi.sm.masterTarget.Get(smi).GetComponent <Ownables>();
                AssignableSlot         clinic    = Db.Get().AssignableSlots.Clinic;
                AssignableSlotInstance slot      = component.GetSlot(clinic);

                if (slot == null || (Object)slot.assignable != (Object)null)
                {
                    return;
                }
                component.AutoAssignSlot(clinic);
            }
Exemplo n.º 9
0
 public void Refresh(object data = null)
 {
     if (!sideScreen.targetAssignable.CanAssignTo(targetIdentity))
     {
         currentState        = AssignableState.Disabled;
         assignmentText.text = UI.UISIDESCREENS.ASSIGNABLESIDESCREEN.DISABLED;
     }
     else if (sideScreen.targetAssignable.assignee == targetIdentity)
     {
         currentState        = AssignableState.Selected;
         assignmentText.text = UI.UISIDESCREENS.ASSIGNABLESIDESCREEN.ASSIGNED;
     }
     else
     {
         bool           flag           = false;
         KMonoBehaviour kMonoBehaviour = targetIdentity as KMonoBehaviour;
         if ((UnityEngine.Object)kMonoBehaviour != (UnityEngine.Object)null)
         {
             Ownables component = kMonoBehaviour.GetComponent <Ownables>();
             if ((UnityEngine.Object)component != (UnityEngine.Object)null)
             {
                 AssignableSlotInstance slot = component.GetSlot(sideScreen.targetAssignable.slot);
                 if (slot != null && slot.IsAssigned())
                 {
                     currentState        = AssignableState.AssignedToOther;
                     assignmentText.text = slot.assignable.GetProperName();
                     flag = true;
                 }
             }
             Equipment component2 = kMonoBehaviour.GetComponent <Equipment>();
             if ((UnityEngine.Object)component2 != (UnityEngine.Object)null)
             {
                 AssignableSlotInstance slot2 = component2.GetSlot(sideScreen.targetAssignable.slot);
                 if (slot2 != null && slot2.IsAssigned())
                 {
                     currentState        = AssignableState.AssignedToOther;
                     assignmentText.text = slot2.assignable.GetProperName();
                     flag = true;
                 }
             }
         }
         if (!flag)
         {
             currentState        = AssignableState.Unassigned;
             assignmentText.text = UI.UISIDESCREENS.ASSIGNABLESIDESCREEN.UNASSIGNED;
         }
     }
     toggle.ChangeState((int)currentState);
 }
Exemplo n.º 10
0
 public virtual void Assign(IAssignableIdentity new_assignee)
 {
     if (new_assignee != assignee)
     {
         if (new_assignee is KMonoBehaviour)
         {
             if (!CanAssignTo(new_assignee))
             {
                 return;
             }
             assignee_identityRef.Set((KMonoBehaviour)new_assignee);
             assignee_groupID = string.Empty;
         }
         else if (new_assignee is AssignmentGroup)
         {
             assignee_identityRef.Set(null);
             assignee_groupID = ((AssignmentGroup)new_assignee).id;
         }
         GetComponent <KPrefabID>().AddTag(GameTags.Assigned, false);
         assignee = new_assignee;
         if (slot != null && (new_assignee is MinionIdentity || new_assignee is StoredMinionIdentity || new_assignee is MinionAssignablesProxy))
         {
             Ownables soleOwner = new_assignee.GetSoleOwner();
             if ((UnityEngine.Object)soleOwner != (UnityEngine.Object)null)
             {
                 soleOwner.GetSlot(slot)?.Assign(this);
             }
             Equipment component = soleOwner.GetComponent <Equipment>();
             if ((UnityEngine.Object)component != (UnityEngine.Object)null)
             {
                 component.GetSlot(slot)?.Assign(this);
             }
         }
         if (this.OnAssign != null)
         {
             this.OnAssign(new_assignee);
         }
         Trigger(684616645, new_assignee);
     }
 }