Skip to content

Commit

Permalink
Merge branch 'master' into ce-lag-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyNova authored Jun 3, 2019
2 parents 51f1915 + 7f7162a commit 83375a1
Show file tree
Hide file tree
Showing 30 changed files with 1,335 additions and 103 deletions.
10 changes: 8 additions & 2 deletions About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
<ModMetaData>
<name>Doors Expanded</name>
<author>Jecrell</author>
<targetVersion>1.0.2059</targetVersion>
<supportedVersions>
<li>1.0</li>
</supportedVersions>
<url>https://discord.gg/AaVFA7V</url>
<description>1.20.0.5 (04-11-2019)
<description>1.20.0.6 (06-02-2019)

Adds new types and sizes of doors to RimWorld.

Expand Down Expand Up @@ -34,6 +36,10 @@ Maaxar, Shibby Says, TheJagermeister, Cory Bonifay, Kiya Nicoll, Matt Harris, Pa
========================
Changelog
========================
1.20.0.6 (06-02-2019)
========================
Remote doors can be secured and locked properly. Also pathing fixes.

1.20.0.5 (04-11-2019)
========================
Adds research for remote buttons and doors as well. Updates Japanese translation.
Expand Down
4 changes: 4 additions & 0 deletions About/Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.20.0.6 (06-02-2019)
========================
Remote doors can be secured and locked properly. Also pathing fixes.

1.20.0.5 (04-11-2019)
========================
Adds research for remote buttons and doors as well. Updates Japanese translation.
Expand Down
2 changes: 1 addition & 1 deletion About/Manifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manifest>
<identifier>DoorsExpanded</identifier>
<version>1.20.0.5</version>
<version>1.20.0.6</version>
<dependencies>
<li>JecsTools</li>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion About/Version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.20.0.5
1.20.0.6
Binary file modified Assemblies/DoorsExpanded.dll
Binary file not shown.
10 changes: 10 additions & 0 deletions Defs/JobDefs/PH_Jobs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>

<JobDef>
<defName>PH_FlipOrPress</defName>
<driverClass>DoorsExpanded.JobDriver_PushButton</driverClass>
<reportString>using TargetA.</reportString>
</JobDef>

</Defs>
4 changes: 4 additions & 0 deletions Defs/ThingDef_Building/Heron_RemoteDoorsAndButtons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<thingClass>DoorsExpanded.Building_DoorRemoteButton</thingClass>
<category>Building</category>
<defaultPlacingRot>South</defaultPlacingRot>
<hasInteractionCell>true</hasInteractionCell>
<interactionCellOffset>(0,0,1)</interactionCellOffset>
<building>
<isEdifice>false</isEdifice>
<fullGraveGraphicData>
Expand Down Expand Up @@ -86,6 +88,8 @@
<thingClass>DoorsExpanded.Building_DoorRemoteButton</thingClass>
<category>Building</category>
<defaultPlacingRot>South</defaultPlacingRot>
<hasInteractionCell>true</hasInteractionCell>
<interactionCellOffset>(0,0,1)</interactionCellOffset>
<building>
<isEdifice>false</isEdifice>
<fullGraveGraphicData>
Expand Down
18 changes: 18 additions & 0 deletions Defs/WorkGiverDefs/PH_WorkGivers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>

<WorkGiverDef>
<defName>PH_PressOrFlip</defName>
<label>use TargetA</label>
<giverClass>DoorsExpanded.WorkGiver_PressOrFlip</giverClass>
<workType>BasicWorker</workType>
<priorityInType>81</priorityInType>
<verb>use</verb>
<gerund>using</gerund>
<requiredCapacities>
<li>Manipulation</li>
</requiredCapacities>
<nonColonistsCanDo>true</nonColonistsCanDo>
</WorkGiverDef>

</Defs>
11 changes: 10 additions & 1 deletion Languages/English/Keyed/ProjectHeron_Keys.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<LanguageData>

<PH_ButtonConnect>Connect to a button</PH_ButtonConnect>
<PH_ButtonDisconnect>Disconnect button or lever</PH_ButtonDisconnect>
<PH_ButtonDisconnectDesc>Disconnects any connected button or lever.</PH_ButtonDisconnectDesc>
<PH_CannotOpenRemotelyWithoutPower>{0} requires power to be opened remotely.</PH_CannotOpenRemotelyWithoutPower>
<PH_PowerSourceRequired>A power source is required.</PH_PowerSourceRequired>
<PH_NeedsLinkedDoorsFirst>A linked remote door is required.</PH_NeedsLinkedDoorsFirst>
<PH_UseButtonOrLever>Use button or lever</PH_UseButtonOrLever>
<PH_UseButtonOrLeverDesc>Toggles whether or not a colonist should make their way over to activate or deactivate the button or lever.</PH_UseButtonOrLeverDesc>
<PH_PowerNeeded>Connect a power source to secure remotely.</PH_PowerNeeded>
<PH_ButtonNeeded>Connect a button or lever to secure remotely.</PH_ButtonNeeded>
<PH_ButtonConnect>Connect to a button or lever</PH_ButtonConnect>
<PH_ButtonConnectDesc>Instantly links the remote door to a button</PH_ButtonConnectDesc>
<PH_ButtonConnectSuccess>Successfully set new button at {0}</PH_ButtonConnectSuccess>
<PH_ButtonConnectFailed>Failed to set new button from {0}</PH_ButtonConnectFailed>
Expand Down
Binary file modified Source/.vs/ProjectHeron/v15/.suo
Binary file not shown.
Binary file modified Source/.vs/ProjectHeron/v15/Server/sqlite3/storage.ide
Binary file not shown.
Binary file modified Source/.vs/ProjectHeron/v15/Server/sqlite3/storage.ide-shm
Binary file not shown.
Binary file modified Source/.vs/ProjectHeron/v15/Server/sqlite3/storage.ide-wal
Binary file not shown.
15 changes: 12 additions & 3 deletions Source/Building_DoorExpanded.cs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ public static void DrawDoubleSwingParams(DoorExpandedDef thingDef, Vector3 drawP
#region Building_Door Copy

private bool openInt;
private bool holdOpenInt;
protected bool holdOpenInt;
protected int ticksUntilClose;
private int lastFriendlyTouchTick = -9999;
protected int visualTicksOpen;
Expand All @@ -444,6 +444,11 @@ public bool SlowsPawns
}
}

public virtual bool PawnCanOpenSpecialCases(Pawn p)
{
return true;
}


// RimWorld.Building_Door
public virtual bool PawnCanOpen(Pawn p)
Expand All @@ -458,16 +463,20 @@ public virtual bool PawnCanOpen(Pawn p)


// RimWorld.Building_Door
public void Notify_PawnApproaching(Pawn p)
public virtual void Notify_PawnApproaching(Pawn p)
{
//Log.Message("PawnPawn!");
if (crossingPawns.Contains(p)) return;
//Log.Message("PawnPawn!2");
//Log.Message("PawnPawn!3");

if (p.InAggroMentalState && p.AnimalOrWildMan())
return;

if (!p.HostileTo(this))
if (!p.HostileTo(this) && !this.IsForbidden(p))
{
this.FriendlyTouched(p);
return;
}

if (this.PawnCanOpen(p))
Expand Down
10 changes: 10 additions & 0 deletions Source/Building_DoorRegionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ public bool OpenValue
set => Traverse.Create(this).Field("openInt").SetValue(value);
}

public override bool BlocksPawn(Pawn p)
{
return base.BlocksPawn(p) || ParentDoor.BlocksPawn(p);
}

public override bool PawnCanOpen(Pawn p)
{
return base.PawnCanOpen(p) && ParentDoor.PawnCanOpenSpecialCases(p);
}

public void OpenMe(int ticks)
{
this.ticksUntilClose = ticks;
Expand Down
135 changes: 127 additions & 8 deletions Source/Building_DoorRemote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,89 @@ public class Building_DoorRemote : Building_DoorExpanded
{
private Building_DoorRemoteButton button = null;
private DoorRemote_State remoteState = DoorRemote_State.Free;
private bool securedRemotely = true;

private bool securedRemotely = false;

public DoorRemote_State RemoteState => remoteState;

public bool SecuredRemotely
{
get => securedRemotely;
set
{
if (value == false && remoteState == DoorRemote_State.ForcedClose)
{
remoteState = DoorRemote_State.Free;
foreach (var invisDoor in InvisDoors)
{
invisDoor.SetForbidden(false);
}
}

if (value == true)
{
var error = "";
if (button == null)
error = "PH_ButtonNeeded".Translate();

if (!this.DoorPowerOn)
error = "PH_PowerNeeded".Translate();

if (error != "")
{
Messages.Message(error, MessageTypeDefOf.RejectInput);
securedRemotely = false;
return;
}
if (remoteState == DoorRemote_State.Free && !this.Open)
{
remoteState = DoorRemote_State.ForcedClose;
foreach (var invisDoor in InvisDoors)
{
invisDoor.SetForbidden(true);
}
}
}
securedRemotely = value;
}
}


public override void Draw()
{

if (!this.Spawned) return;
if (SecuredRemotely && remoteState == DoorRemote_State.ForcedClose)
{
var drawLoc = this.DrawPos;
drawLoc.y = Altitudes.AltitudeFor(AltitudeLayer.MetaOverlays) + 0.28125f;
var num = (Time.realtimeSinceStartup + 397f * (float)(this.thingIDNumber % 571)) * 1.5f;
var num2 = ((float)Math.Sin((double)num) + 1f) * 0.3f;
num2 = 0.3f + num2 * 0.7f;
var mesh = MeshPool.plane05;
var mat = TexOverlay.LockedOverlay;
var material = FadedMaterialPool.FadedVersionOf(mat, num2);
Graphics.DrawMesh(mesh, drawLoc, Quaternion.identity, material, 0);
}
base.Draw();
}

public override bool WillCloseSoon => remoteState != DoorRemote_State.ForcedOpen && base.WillCloseSoon;

public override bool PawnCanOpen(Pawn p)
public override void Notify_PawnApproaching(Pawn p)
{
if (remoteState != DoorRemote_State.ForcedOpen && SecuredRemotely)
return;
base.Notify_PawnApproaching(p);
}

public override bool BlocksPawn(Pawn p)
{
return base.BlocksPawn(p) || (SecuredRemotely && remoteState != DoorRemote_State.ForcedOpen);
}

public override bool PawnCanOpenSpecialCases(Pawn p)
{
return remoteState != DoorRemote_State.ForcedClose && base.PawnCanOpen(p);
return (remoteState == DoorRemote_State.Free || remoteState == DoorRemote_State.ForcedOpen) && base.PawnCanOpenSpecialCases(p);
}

public override bool ShouldKeepDoorOpen()
Expand All @@ -48,7 +113,7 @@ public override void DrawExtraSelectionOverlays()
if (button != null)
GenDraw.DrawLineBetween(this.TrueCenter(), button.TrueCenter());
base.DrawExtraSelectionOverlays();
}
}



Expand All @@ -66,7 +131,20 @@ public override IEnumerable<Gizmo> GetGizmos()
disabledReason = "",
action = ConnectToButton
};


if (button != null)
{
yield return new Command_Action()
{
defaultLabel = "PH_ButtonDisconnect".Translate(),
defaultDesc = "PH_ButtonDisconnectDesc".Translate(),
icon = TexButton.DisconnectButton,
disabled = false,
disabledReason = "",
action = ClearButton
};
}

yield return new Command_Toggle()
{
defaultLabel = "PH_RemoteDoorSecuredRemotely".Translate(),
Expand All @@ -81,21 +159,46 @@ public override IEnumerable<Gizmo> GetGizmos()

public void Notify_ButtonPushed()
{
if (this.PowerComp != null && !this.DoorPowerOn)
{
Messages.Message("PH_CannotOpenRemotelyWithoutPower".Translate(this.Label), this, MessageTypeDefOf.RejectInput);
return;
}

if (this.Open)
{
holdOpenInt = false;
this.DoorTryClose();
if (!securedRemotely)
if (!SecuredRemotely)
remoteState = DoorRemote_State.Free;
else
{
remoteState = DoorRemote_State.ForcedClose;
foreach (var invisDoor in InvisDoors)
{
invisDoor.SetForbidden(true);
}
}
}
else
{
this.DoorOpen(int.MaxValue);
holdOpenInt = true;
remoteState = DoorRemote_State.ForcedOpen;
foreach (var invisDoor in InvisDoors)
{
invisDoor.SetForbidden(false);
}
}
}

private void ClearButton()
{
if (this.button != null)
button.Notify_Unlinked(this);
button = null;
}

private void ConnectToButton()
{
TargetingParameters tp = new TargetingParameters();
Expand Down Expand Up @@ -133,7 +236,23 @@ public override void ExposeData()
base.ExposeData();
Scribe_References.Look(ref this.button, "button");
Scribe_Values.Look(ref this.remoteState, "remoteState", DoorRemote_State.Free);
Scribe_Values.Look(ref this.securedRemotely, "strictPolicy", true);
Scribe_Values.Look(ref this.securedRemotely, "securedRemotely", true);
if (Scribe.mode == LoadSaveMode.PostLoadInit)
{
if (SecuredRemotely && remoteState == DoorRemote_State.ForcedClose)
{
this.DoorTryClose();
foreach (var invisDoor in InvisDoors)
{
invisDoor.SetForbidden(true);
}
}
if (remoteState == DoorRemote_State.ForcedOpen)
{
this.DoorOpen(int.MaxValue);
holdOpenInt = true;
}
}
}
}
}
Loading

0 comments on commit 83375a1

Please sign in to comment.