public LockGizmo(ThingWithComps thing, LockComp lockComp) { lockThing = thing; this.lockComp = lockComp; targetingParams = new TargetingParameters { thingCategory = ThingCategory.Building, canTargetPawns = false, canTargetBuildings = true, canTargetItems = false, onlyTargetFactions = new List <Faction>(1) { Find.FactionManager.OfPlayer }, validator = delegate(TargetInfo target) { var t = target.Thing as ThingWithComps; if (t != null && t.HasDoorLock(out _)) { return(true); } return(false); } }; action = delegate(Thing door) { var manager = door.Map.designationManager; var desig = manager.DesignationOn(door, DesignationDefOf.ModifyDoorLock); if (desig == null) { door.Map.designationManager.AddDesignation(new Designation(door, DesignationDefOf.ModifyDoorLock)); } }; }
public override void CompTick() { if (!toggling) { return; } if (progressBar != null) { if (progressBar.ticksLeft <= 0) { progressBar.ticksLeft = 1; } var progress = locksToToggle.Where(t => t.State.IsState(assignedState)).Count(); progressBar.EffectTick(parent, keyHolder?.Pawn ?? TargetInfo.Invalid); var mote = ((SubEffecter_ProgressBar)progressBar.children[0]).mote; if (mote != null) { mote.progress = Mathf.Clamp01((float)progress / locksToToggle.Count); mote.offsetZ = CompProp.progressBarOffset; } } if (assignedState.IsLocked() && Door.Open) { return; } if (currLock == null) { currLock = GetNextLockToToggle(); } if (currLock != null) { if (currLock.Toggling) { return; } currLock = GetNextLockToToggle(); currLock?.StartToggle(keyHolder, progressBar != null); return; } else if (!LockComps.Any(t => t.Toggling)) { if (progressBar != null) { progressBar.Cleanup(); progressBar = null; } toggling = false; locksToToggle.Clear(); } }
public void RemoveLock(LockComp lockComp, ThingOwner outOwner = null, Map map = null, IntVec3 pos = default) { if (lockComp.installedThing != parent) { return; } lockComp.installedThing = null; lockComp.postToggle = null; locks.RemoveAll(t => t.comp == lockComp); if (outOwner == null) { lockOwner.TryDrop(lockComp.parent, map != null ? pos : parent.PositionHeld, map != null ? map : parent.MapHeld, ThingPlaceMode.Near, out _); } else { lockOwner.TryTransferToContainer(lockComp.parent, outOwner, false); } }
public void InstallLock(LockComp lockComp) { var pair = new LockComp.LockThingPair(lockComp.parent, lockComp); InstallLock(pair); }
public static Toil LockUnlockLock(KeyHolderComp keyHolder, LockComp lockComp) => Toils_General.Do(delegate { lockComp.StartToggle(false, keyHolder, true); keyHolder.Pawn.stances.SetStance(new Stance_ToggleLock(lockComp.CompProp.unlockTime, lockComp.parent, null)); });
public static bool IsLock(this ThingWithComps thing, out LockComp lockComp) => (lockComp = thing.TryGetComp <LockComp>()) != null;
public LockThingPair(ThingWithComps thing, LockComp comp) { this.thing = thing; this.comp = comp; }
public bool CanUnlock(LockComp lockComp) { return(true); }