-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from thomasfn/staging
release 0.7.0
- Loading branch information
Showing
13 changed files
with
165 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using System.Linq; | ||
|
||
namespace Eco.Mods.LawExtensions | ||
{ | ||
using Core.Controller; | ||
using Core.Utils; | ||
using Core.Utils.PropertyScanning; | ||
|
||
using Shared.Localization; | ||
using Shared.Networking; | ||
using Shared.Utils; | ||
using Shared.Math; | ||
|
||
using Gameplay.Civics.GameValues; | ||
|
||
[Eco, LocCategory("World"), LocDescription("The X coord of a location.")] | ||
public class XCoordAt : GameValue<float> | ||
{ | ||
[Eco, Advanced, LocDescription("The position to read the X coord of.")] public GameValue<Vector3i> Location { get; set; } | ||
|
||
private Eval<float> FailNullSafeFloat<T>(Eval<T> eval, string paramName) => | ||
eval != null ? Eval.Make($"Invalid {Localizer.DoStr(paramName)} specified on {GetType().GetLocDisplayName()}: {eval.Message}", float.MinValue) | ||
: Eval.Make($"{Localizer.DoStr(paramName)} not set on {GetType().GetLocDisplayName()}.", float.MinValue); | ||
|
||
public override Eval<float> Value(IContextObject action) | ||
{ | ||
var location = this.Location?.Value(action); if (location?.Val == null) return this.FailNullSafeFloat(location, nameof(this.Location)); | ||
|
||
var value = location.Val.X; | ||
return Eval.Make($"{Text.StyledNum(value)} (X coord)", (float)value); | ||
} | ||
public override LocString Description() => Localizer.Do($"X coord"); | ||
} | ||
|
||
[Eco, LocCategory("World"), LocDescription("The Z coord of a location.")] | ||
public class ZCoordAt : GameValue<float> | ||
{ | ||
[Eco, Advanced, LocDescription("The position to read the Z coord of.")] public GameValue<Vector3i> Location { get; set; } | ||
|
||
private Eval<float> FailNullSafeFloat<T>(Eval<T> eval, string paramName) => | ||
eval != null ? Eval.Make($"Invalid {Localizer.DoStr(paramName)} specified on {GetType().GetLocDisplayName()}: {eval.Message}", float.MinValue) | ||
: Eval.Make($"{Localizer.DoStr(paramName)} not set on {GetType().GetLocDisplayName()}.", float.MinValue); | ||
|
||
public override Eval<float> Value(IContextObject action) | ||
{ | ||
var location = this.Location?.Value(action); if (location?.Val == null) return this.FailNullSafeFloat(location, nameof(this.Location)); | ||
|
||
var value = location.Val.Z; | ||
return Eval.Make($"{Text.StyledNum(value)} (Z coord)", (float)value); | ||
} | ||
public override LocString Description() => Localizer.Do($"Z coord"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.