Skip to content

Commit

Permalink
v3.5.2 better pos for drafted colonist and undrafted mechs
Browse files Browse the repository at this point in the history
  • Loading branch information
pardeike committed Oct 30, 2022
1 parent 1583c47 commit eeb3940
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
Binary file modified 1.4/Assemblies/AchtungMod.dll
Binary file not shown.
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>net.pardeike.rimworld.mod.achtung</identifier>
<version>3.5.1.0</version>
<version>3.5.2.0</version>
<targetVersions>
<li>1.0.0</li>
<li>1.1.0</li>
Expand Down
2 changes: 1 addition & 1 deletion Source/Achtung.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<OutputPath>..\1.4\Assemblies\</OutputPath>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<Version>3.5.1.0</Version>
<Version>3.5.2.0</Version>
<Copyright>© July, 2016</Copyright>
</PropertyGroup>

Expand Down
28 changes: 17 additions & 11 deletions Source/Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public bool MouseDown(Vector3 pos)

var actions = new MultiActions(colonists, UI.MouseMapPosition());
var achtungPressed = Tools.IsModKeyPressed(Achtung.Settings.achtungKey);
var allDrafted = colonists.All(colonist => colonist.pawn.Drafted || achtungPressed);
var allDrafted = colonists.All(colonist => colonist.pawn.Drafted || colonist.pawn.IsColonyMechPlayerControlled || achtungPressed);
var mixedDrafted = !allDrafted && colonists.Any(colonist => colonist.pawn.Drafted);

var forceMenu = false;
Expand Down Expand Up @@ -155,22 +155,24 @@ public bool MouseDown(Vector3 pos)

private void StartDragging(Vector3 pos, bool asGroup)
{
groupMovement = asGroup;
var draftedColonists = colonists.Where(colonist => colonist.pawn.Drafted).ToList();

groupMovement = asGroup;
if (groupMovement)
{
groupCenter.x = colonists.Sum(colonist => colonist.startPosition.x) / colonists.Count;
groupCenter.z = colonists.Sum(colonist => colonist.startPosition.z) / colonists.Count;
groupCenter.x = draftedColonists.Sum(colonist => colonist.startPosition.x) / draftedColonists.Count;
groupCenter.z = draftedColonists.Sum(colonist => colonist.startPosition.z) / draftedColonists.Count;
groupRotation = 0;
groupRotationWas45 = Tools.Has45DegreeOffset(colonists);
groupRotationWas45 = Tools.Has45DegreeOffset(draftedColonists);
}
else
{
lineStart = pos;
lineStart.y = Altitudes.AltitudeFor(AltitudeLayer.MetaOverlays);
}

colonists.Do(colonist => colonist.offsetFromCenter = colonist.startPosition - groupCenter);
draftedColonists
.Do(colonist => colonist.offsetFromCenter = colonist.startPosition - groupCenter);

isDragging = true;
Event.current.Use();
Expand All @@ -189,6 +191,8 @@ private void EndDragging()

public void MouseDrag(Vector3 pos)
{
var draftedColonists = colonists.Where(colonist => colonist.pawn.Drafted).ToList();

if (Event.current.button != (int)Button.right)
return;

Expand All @@ -197,19 +201,19 @@ public void MouseDrag(Vector3 pos)

if (groupMovement)
{
colonists.Do(colonist => colonist.OrderTo(pos + Tools.RotateBy(colonist.offsetFromCenter, groupRotation, groupRotationWas45)));
draftedColonists.Do(colonist => colonist.OrderTo(pos + Tools.RotateBy(colonist.offsetFromCenter, groupRotation, groupRotationWas45)));
Event.current.Use();
return;
}

lineEnd = pos;
lineEnd.y = Altitudes.AltitudeFor(AltitudeLayer.MetaOverlays);
var count = colonists.Count;
var count = draftedColonists.Count;
var dragVector = lineEnd - lineStart;

var delta = count > 1 ? dragVector / (count - 1) : Vector3.zero;
var linePosition = count == 1 ? lineEnd : lineStart;
Tools.OrderColonistsAlongLine(colonists, lineStart, lineEnd).Do(colonist =>
Tools.OrderColonistsAlongLine(draftedColonists, lineStart, lineEnd).Do(colonist =>
{
colonist.OrderTo(linePosition);
linePosition += delta;
Expand Down Expand Up @@ -241,6 +245,8 @@ public void KeyDown(KeyCode key)
}
}

var draftedColonists = colonists.Where(colonist => colonist.pawn.Drafted).ToList();

switch (key)
{
case KeyCode.Q:
Expand All @@ -249,7 +255,7 @@ public void KeyDown(KeyCode key)
groupRotation -= 45;

var pos = UI.MouseMapPosition();
colonists.Do(colonist => colonist.OrderTo(pos + Tools.RotateBy(colonist.offsetFromCenter, groupRotation, groupRotationWas45)));
draftedColonists.Do(colonist => colonist.OrderTo(pos + Tools.RotateBy(colonist.offsetFromCenter, groupRotation, groupRotationWas45)));

Event.current.Use();
}
Expand All @@ -261,7 +267,7 @@ public void KeyDown(KeyCode key)
groupRotation += 45;

var pos = UI.MouseMapPosition();
colonists.Do(colonist => colonist.OrderTo(pos + Tools.RotateBy(colonist.offsetFromCenter, groupRotation, groupRotationWas45)));
draftedColonists.Do(colonist => colonist.OrderTo(pos + Tools.RotateBy(colonist.offsetFromCenter, groupRotation, groupRotationWas45)));

Event.current.Use();
}
Expand Down

0 comments on commit eeb3940

Please sign in to comment.