Skip to content

Commit

Permalink
Add some actions. Add latest libs of Unturned.
Browse files Browse the repository at this point in the history
  • Loading branch information
DiFFoZ committed Oct 31, 2020
1 parent bf8a51f commit 4961786
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Dummy/Extensions/Interaction/Actions/Barricade/ClaimBedAction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Cysharp.Threading.Tasks;
using Dummy.Users;
using SDG.Unturned;
using System.Threading.Tasks;
using UnityEngine;

namespace Dummy.Extensions.Interaction.Actions.Barricade
{
public class ClaimBedAction : IInteractionAction
{
public ClaimBedAction(byte x, byte y, ushort plant, ushort index)
{
X = x;
Y = y;
Plant = plant;
Index = index;
}

public ClaimBedAction(Transform barricade)
{
if (BarricadeManager.tryGetInfo(barricade, out var x, out var y, out var plant, out var index, out _))
{
X = x;
Y = y;
Plant = plant;
Index = index;
}
}

public byte X { get; }
public byte Y { get; }
public ushort Plant { get; }
public ushort Index { get; }

public async Task Do(DummyUser dummy)
{
await UniTask.SwitchToMainThread();
BarricadeManager.instance.askClaimBed(dummy.SteamID, X, Y, Plant, Index);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Cysharp.Threading.Tasks;
using Dummy.Users;
using SDG.Unturned;
using System.Threading.Tasks;
using UnityEngine;

namespace Dummy.Extensions.Interaction.Actions.Barricade
{
public class SalvageBarricadeAction : IInteractionAction
{
public SalvageBarricadeAction(byte x, byte y, ushort plant, ushort index)
{
X = x;
Y = y;
Plant = plant;
Index = index;
}

public SalvageBarricadeAction(Transform barricade)
{
if (BarricadeManager.tryGetInfo(barricade, out var x, out var y, out var plant, out var index, out _))
{
X = x;
Y = y;
Plant = plant;
Index = index;
}
}

public byte X { get; }
public byte Y { get; }
public ushort Plant { get; }
public ushort Index { get; }

public async Task Do(DummyUser dummy)
{
await UniTask.SwitchToMainThread();
BarricadeManager.instance.askSalvageBarricade(dummy.SteamID, X, Y, Plant, Index);
}
}
}
33 changes: 33 additions & 0 deletions Dummy/Extensions/Interaction/Actions/Vehicle/EnterVehicleAction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Cysharp.Threading.Tasks;
using Dummy.Users;
using SDG.Unturned;
using System;
using System.Threading.Tasks;

namespace Dummy.Extensions.Interaction.Actions.Vehicle
{
public class EnterVehicleAction : IInteractionAction
{
private readonly InteractableVehicle m_InteractableVehicle;
public uint InstanceId { get; }

public EnterVehicleAction(InteractableVehicle interactableVehicle)
{
InstanceId = interactableVehicle.instanceID;
m_InteractableVehicle = interactableVehicle;
}

public EnterVehicleAction(uint instanceId)
{
InstanceId = instanceId;
m_InteractableVehicle = VehicleManager.findVehicleByNetInstanceID(instanceId);
}

public async Task Do(DummyUser dummy)
{
await UniTask.SwitchToMainThread();
VehicleManager.instance.askEnterVehicle(dummy.SteamID, InstanceId, m_InteractableVehicle.asset.hash,
(byte)m_InteractableVehicle.asset.engine);
}
}
}
33 changes: 33 additions & 0 deletions Dummy/Extensions/Interaction/Actions/Vehicle/ExitVehicleAction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Cysharp.Threading.Tasks;
using Dummy.Users;
using SDG.Unturned;
using System;
using System.Threading.Tasks;
using UnityEngine;

namespace Dummy.Extensions.Interaction.Actions.Vehicle
{
public class ExitVehicleAction : IInteractionAction
{
private readonly InteractableVehicle m_InteractableVehicle;
public uint InstanceId { get; }

public ExitVehicleAction(uint instanceId)
{
InstanceId = instanceId;
m_InteractableVehicle = VehicleManager.findVehicleByNetInstanceID(instanceId)
?? throw new ArgumentException(nameof(m_InteractableVehicle));
}

public ExitVehicleAction(InteractableVehicle interactableVehicle)
{
InstanceId = interactableVehicle.instanceID;
}

public async Task Do(DummyUser dummy)
{
await UniTask.SwitchToMainThread();
VehicleManager.instance.askExitVehicle(dummy.SteamID, Vector3.zero);
}
}
}
Binary file added libs/Assembly-CSharp-firstpass.dll
Binary file not shown.
Binary file added libs/Assembly-CSharp.dll
Binary file not shown.

0 comments on commit 4961786

Please sign in to comment.