Skip to content

Commit

Permalink
tweak moder power
Browse files Browse the repository at this point in the history
  • Loading branch information
zolantris committed May 21, 2024
1 parent 808896a commit 9ad4e96
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 23 deletions.
23 changes: 7 additions & 16 deletions src/ValheimRAFT/ValheimRAFT/ValheimRaftPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,9 @@ private void CreateServerConfig()
{
ProtectVehiclePiecesOnErrorFromWearNTearDamage = Config.Bind("Server config",
"Protect Vehicle pieces from breaking on Error", true,
"Protects against crashes breaking raft/vehicle initialization causing raft/vehicles to slowly break pieces attached to it. This will make pieces attached to valid raft ZDOs unbreakable from damage, but still breakable with hammer");
CreateConfigDescription(
"Protects against crashes breaking raft/vehicle initialization causing raft/vehicles to slowly break pieces attached to it. This will make pieces attached to valid raft ZDOs unbreakable from damage, but still breakable with hammer",
true, true));
AdminsCanOnlyBuildRaft = Config.Bind("Server config", "AdminsCanOnlyBuildRaft", false,
CreateConfigDescription(
"ValheimRAFT hammer menu pieces are registered as disabled unless the user is an Admin, allowing only admins to create rafts. This will update automatically make sure to un-equip the hammer to see it apply (if your remove yourself as admin). Server / client does not need to restart",
Expand All @@ -261,26 +263,15 @@ private void CreateServerConfig()
"Allows the V1 Raft to be built, this Raft is not performant, but remains in >=v2.0.0 as a Fallback in case there are problems with the new raft",
true, true));
AllowExperimentalPrefabs = Config.Bind("Server config", "AllowExperimentalPrefabs", false,
new ConfigDescription(
CreateConfigDescription(
"Allows >=v2.0.0 experimental prefabs such as Iron variants of slabs, hulls, and ribs. They do not look great so they are disabled by default",
null, [
new ConfigurationManagerAttributes()
{
IsAdminOnly = true
}
]));
true, true));

ForceShipOwnerUpdatePerFrame = Config.Bind("Rendering",
"Force Ship Owner Piece Update Per Frame", false,
new ConfigDescription(
CreateConfigDescription(
"Forces an update during the Update sync of unity meaning it fires every frame for the Ship owner who also owns Physics. This will possibly make updates better for non-boat owners. Noting that the boat owner is determined by the first person on the boat, otherwise the game owns it.",
null, [
new ConfigurationManagerAttributes()
{
IsAdminOnly = true,
IsAdvanced = true,
}
]));
true, true));

ServerRaftUpdateZoneInterval = Config.Bind("Server config",
"ServerRaftUpdateZoneInterval",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class SteeringWheelComponent : MonoBehaviour, Hoverable, Interactable, ID
public MoveableBaseShipComponent deprecatedMBShip;

public IVehicleShip ShipInstance;
public static readonly int PlayerSteeringAnim = ZSyncAnimation.GetHash("player_steering");
public Transform? wheelTransform;
private Vector3 wheelLocalOffset;

Expand Down Expand Up @@ -53,7 +52,6 @@ public class SteeringWheelComponent : MonoBehaviour, Hoverable, Interactable, ID
private const float maxUseRange = 10f;
public Transform AttachPoint { get; set; }

public ZSyncAnimation zAnimation;

public static string GetAnchorHotkeyString()
{
Expand Down Expand Up @@ -132,7 +130,6 @@ private void Awake()
AttachPoint = transform.Find("attachpoint");
wheelTransform = transform.Find("controls/wheel");
wheelLocalOffset = wheelTransform.position - transform.position;
// zAnimation = gameObject.AddComponent<ZSyncAnimation>();
}

public string GetHoverName()
Expand Down Expand Up @@ -386,8 +383,6 @@ public void UpdateIK(Animator animator)
return;
}

// zAnimation.m_animator = animator;

if (!m_currentLeftHand)
{
var playerHandTransform = transform.TransformPoint(m_leftHandPosition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,10 @@ public void OnDestroyed()
s_currentShips.Remove(this);
}

/// <summary>
/// If moder power is enabled
/// </summary>
/// <returns></returns>
public bool IsWindControllActive()
{
foreach (Player player in m_players)
Expand Down
6 changes: 4 additions & 2 deletions src/ValheimVehicles/ValheimVehicles.Vehicles/VehicleShip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1127,8 +1127,9 @@ public void UpdateSail(float deltaTime)
mainCamera.transform.InverseTransformDirection(ShipDirection.forward));
}

public new float GetWindAngle()
public float GetWindAngle()
{
// moder power support
var isWindPowerActive = IsWindControllActive();

var windDir = isWindPowerActive ? ShipDirection.forward : EnvMan.instance.GetWindDir();
Expand Down Expand Up @@ -1206,7 +1207,7 @@ private void SyncVehicleRotationDependentItems()

private float GetInterpolatedWindAngleFactor()
{
var windIntensity = EnvMan.instance.GetWindIntensity();
var windIntensity = IsWindControllActive() ? 1f : EnvMan.instance.GetWindIntensity();
var interpolatedWindIntensity = Mathf.Lerp(0.25f, 1f, windIntensity);

var windAngleFactor = GetWindAngleFactor();
Expand Down Expand Up @@ -1243,6 +1244,7 @@ private Vector3 GetSailForce(float sailSize, float dt, bool isFlying)

private new float GetWindAngleFactor()
{
if (IsWindControllActive()) return 1f;
var num = Vector3.Dot(EnvMan.instance.GetWindDir(), -ShipDirection!.forward);
var num2 = Mathf.Lerp(0.7f, 1f, 1f - Mathf.Abs(num));
var num3 = 1f - Utils.LerpStep(0.75f, 0.8f, num);
Expand Down

0 comments on commit 9ad4e96

Please sign in to comment.