Skip to content

Commit

Permalink
Added RagdollSpawnPointObject and fixed some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal78900 committed Aug 8, 2021
1 parent 6538060 commit e982220
Show file tree
Hide file tree
Showing 14 changed files with 264 additions and 86 deletions.
26 changes: 26 additions & 0 deletions MapEditorReborn/API/Components/RagdollObjectComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
namespace MapEditorReborn.API
{
using Exiled.API.Features;
using Mirror;
using UnityEngine;

public class RagdollObjectComponent : MonoBehaviour
{
public string RagdollName = string.Empty;

public RoleType RagdollRoleType = RoleType.ClassD;

public Ragdoll AttachedRagdoll = null;

private void Start()
{
AttachedRagdoll = Map.SpawnRagdoll(RagdollRoleType, DamageTypes.None, RagdollName, gameObject.transform.position, gameObject.transform.rotation);
}

private void OnDestroy()
{
if (AttachedRagdoll != null)
NetworkServer.Destroy(AttachedRagdoll.gameObject);
}
}
}
5 changes: 5 additions & 0 deletions MapEditorReborn/API/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,10 @@ public enum ToolGunMode
/// The mode that will spawn a PlayerSpawnPoint.
/// </summary>
PlayerSpawnPoint = 5,

/// <summary>
/// The mode that will spawn a RagdollSpawnPoint.
/// </summary>
RagdollSpawnPoint = 6,
}
}
5 changes: 4 additions & 1 deletion MapEditorReborn/API/Extenstions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ public static GameObject GetObjectByMode(this ToolGunMode toolGunMode)
case ToolGunMode.PlayerSpawnPoint:
return Handler.PlayerSpawnPointObj;

case ToolGunMode.RagdollSpawnPoint:
return Handler.RagdollSpawnPointObj;

default:
return null;
}
Expand Down Expand Up @@ -311,7 +314,7 @@ public static void UpdateObject(this GameObject gameObject, Player player = null
{
Handler.SpawnPickupIndicator(gameObject);
}
else if (gameObject.name == "PlayerSpawnPointObject(Clone)")
else if (gameObject.name == "PlayerSpawnPointObject(Clone)" || gameObject.name == "RagdollSpawnPointObject(Clone)")
{
Handler.SpawnDummyIndicator(gameObject);
}
Expand Down
7 changes: 7 additions & 0 deletions MapEditorReborn/API/MapSchematic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public MapSchematic()
/// </summary>
public bool RemoveDefaultSpawnPoints { get; set; } = false;

public Dictionary<RoleType, List<string>> RoleNames { get; set; } = new Dictionary<RoleType, List<string>>()
{
{ RoleType.ClassD, new List<string>() { "D-9341" } },
};

/// <summary>
/// Gets or sets the list of <see cref="DoorObject"/>.
/// </summary>
Expand All @@ -45,5 +50,7 @@ public MapSchematic()
/// Gets or sets the list of <see cref="PlayerSpawnPointObject"/>.
/// </summary>
public List<PlayerSpawnPointObject> PlayerSpawnPoints { get; set; } = new List<PlayerSpawnPointObject>();

public List<RagdollSpawnPointObject> RagdollSpawnPoints { get; set; } = new List<RagdollSpawnPointObject>();
}
}
44 changes: 22 additions & 22 deletions MapEditorReborn/API/Objects/DoorObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,61 +36,61 @@ public DoorObject(DoorType doorType, Vector3 position, Vector3 rotation, Vector3
}

/// <summary>
/// Gets or sets the door <see cref="DoorType"/>.
/// Gets the door <see cref="DoorType"/>.
/// </summary>
public DoorType DoorType { get; set; }
public DoorType DoorType { get; private set; }

/// <summary>
/// Gets or sets the door's position.
/// Gets the door's position.
/// </summary>
// public Vector3 Position { get; set; } = Vector3.zero;
public SerializableVector3 Position { get; set; } = SerializableVector3.Zero;
public SerializableVector3 Position { get; private set; } = SerializableVector3.Zero;

/// <summary>
/// Gets or sets the door's rotation.
/// Gets the door's rotation.
/// </summary>
// public Vector3 Rotation { get; set; } = Vector3.zero;
public SerializableVector3 Rotation { get; set; } = SerializableVector3.Zero;
public SerializableVector3 Rotation { get; private set; } = SerializableVector3.Zero;

/// <summary>
/// Gets or sets the door's scale.
/// Gets the door's scale.
/// </summary>
// public Vector3 Scale { get; set; } = Vector3.one;
public SerializableVector3 Scale { get; set; } = SerializableVector3.One;
public SerializableVector3 Scale { get; private set; } = SerializableVector3.One;

/// <summary>
/// Gets or sets the <see cref="Exiled.API.Enums.RoomType"/> which is used to determine the spawn pos and rotation of the object.
/// Gets the <see cref="Exiled.API.Enums.RoomType"/> which is used to determine the spawn pos and rotation of the object.
/// </summary>
public RoomType RoomType { get; set; } = RoomType.Unknown;
public RoomType RoomType { get; private set; } = RoomType.Unknown;

/// <summary>
/// Gets or sets a value indicating whether the door is opened or not.
/// Gets a value indicating whether the door is opened or not.
/// </summary>
public bool IsOpen { get; set; } = false;
public bool IsOpen { get; private set; } = false;

/// <summary>
/// Gets or sets a value indicating whether the door is locked or not.
/// Gets a value indicating whether the door is locked or not.
/// </summary>
public bool IsLocked { get; set; } = false;
public bool IsLocked { get; private set; } = false;

/// <summary>
/// Gets or sets a value indicating whether the door has keycard permissions or not.
/// Gets a value indicating whether the door has keycard permissions or not.
/// </summary>
public KeycardPermissions KeycardPermissions { get; set; } = KeycardPermissions.None;
public KeycardPermissions KeycardPermissions { get; private set; } = KeycardPermissions.None;

/// <summary>
/// Gets or sets <see cref="DoorDamageType"/> ignored by the door.
/// Gets <see cref="DoorDamageType"/> ignored by the door.
/// </summary>
public DoorDamageType IgnoredDamageSources { get; set; } = DoorDamageType.Weapon;
public DoorDamageType IgnoredDamageSources { get; private set; } = DoorDamageType.Weapon;

/// <summary>
/// Gets or sets health of the door.
/// Gets health of the door.
/// </summary>
public float DoorHealth { get; set; } = 150f;
public float DoorHealth { get; private set; } = 150f;

/// <summary>
/// Gets or sets a value indicating whether the door will open automatically on warhead activation or not.
/// Gets a value indicating whether the door will open automatically on warhead activation or not.
/// </summary>
public bool OpenOnWarheadActivation { get; set; } = false;
public bool OpenOnWarheadActivation { get; private set; } = false;
}
}
20 changes: 10 additions & 10 deletions MapEditorReborn/API/Objects/ItemSpawnPointObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,30 @@ public ItemSpawnPointObject(string item, Vector3 position, Vector3 rotation, Roo
}

/// <summary>
/// Gets or sets the name of the item that will be spawned (supports CustomItems).
/// Gets the name of the item that will be spawned (supports CustomItems).
/// </summary>
public string Item { get; set; } = "KeycardJanitor";
public string Item { get; private set; } = "KeycardJanitor";

/// <summary>
/// Gets or sets the ItemSpawnPoint's position.
/// Gets the ItemSpawnPoint's position.
/// </summary>
// public Vector3 Position { get; set; } = Vector3.zero;
public SerializableVector3 Position { get; set; } = SerializableVector3.Zero;
public SerializableVector3 Position { get; private set; } = SerializableVector3.Zero;

/// <summary>
/// Gets or sets the ItemSpawnPoint's rotation.
/// Gets the ItemSpawnPoint's rotation.
/// </summary>
// public Vector3 Rotation { get; set; } = Vector3.zero;
public SerializableVector3 Rotation { get; set; } = SerializableVector3.Zero;
public SerializableVector3 Rotation { get; private set; } = SerializableVector3.Zero;

/// <summary>
/// Gets or sets the <see cref="Exiled.API.Enums.RoomType"/> which is used to determine the spawn pos and rotation of the object.
/// Gets the <see cref="Exiled.API.Enums.RoomType"/> which is used to determine the spawn pos and rotation of the object.
/// </summary>
public RoomType RoomType { get; set; } = RoomType.Unknown;
public RoomType RoomType { get; private set; } = RoomType.Unknown;

/// <summary>
/// Gets or sets the spawn chance of the item.
/// Gets the spawn chance of the item.
/// </summary>
public int SpawnChance { get; set; } = 100;
public int SpawnChance { get; private set; } = 100;
}
}
12 changes: 6 additions & 6 deletions MapEditorReborn/API/Objects/PlayerSpawnPointObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ public PlayerSpawnPointObject(RoleType roleType, Vector3 position, RoomType room
}

/// <summary>
/// Gets or sets the role which will spawn on the spawnpoint.
/// Gets the role which will spawn on the spawnpoint.
/// </summary>
public RoleType RoleType { get; set; } = RoleType.Tutorial;
public RoleType RoleType { get; private set; } = RoleType.Tutorial;

/// <summary>
/// Gets or sets the ItemSpawnPoint's position.
/// Gets the ItemSpawnPoint's position.
/// </summary>
// public Vector3 Position { get; set; } = Vector3.zero;
public SerializableVector3 Position { get; set; } = SerializableVector3.Zero;
public SerializableVector3 Position { get; private set; } = SerializableVector3.Zero;

/// <summary>
/// Gets or sets the <see cref="Exiled.API.Enums.RoomType"/> which is used to determine the spawn pos and rotation of the object.
/// Gets the <see cref="Exiled.API.Enums.RoomType"/> which is used to determine the spawn pos and rotation of the object.
/// </summary>
public RoomType RoomType { get; set; } = RoomType.Unknown;
public RoomType RoomType { get; private set; } = RoomType.Unknown;
}
}
36 changes: 36 additions & 0 deletions MapEditorReborn/API/Objects/RagdollSpawnPointObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
namespace MapEditorReborn.API
{
using Exiled.API.Enums;
using System;
using UnityEngine;

[Serializable]
public class RagdollSpawnPointObject
{
/// <summary>
/// Initializes a new instance of the <see cref="RagdollSpawnPointObject"/> class.
/// </summary>
public RagdollSpawnPointObject()
{
}

public RagdollSpawnPointObject(string name, RoleType roleType, Vector3 position, Vector3 rotation, RoomType roomType)
{
Name = name;
RoleType = roleType;
Position = position;
Rotation = rotation;
RoomType = roomType;
}

public string Name { get; private set; } = string.Empty;

public RoleType RoleType { get; private set; } = RoleType.ClassD;

public SerializableVector3 Position { get; private set; } = SerializableVector3.Zero;

public SerializableVector3 Rotation { get; private set; } = SerializableVector3.Zero;

public RoomType RoomType { get; private set; } = RoomType.Unknown;
}
}
16 changes: 8 additions & 8 deletions MapEditorReborn/API/Objects/WorkStationObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,26 @@ public WorkStationObject(Vector3 position, Vector3 rotation, Vector3 scale, Room
}

/// <summary>
/// Gets or sets the workstation's position.
/// Gets the workstation's position.
/// </summary>
// public Vector3 Position { get; set; } = Vector3.zero;
public SerializableVector3 Position { get; set; } = SerializableVector3.Zero;
public SerializableVector3 Position { get; private set; } = SerializableVector3.Zero;

/// <summary>
/// Gets or sets the workstation's rotation.
/// Gets the workstation's rotation.
/// </summary>
// public Vector3 Rotation { get; set; } = Vector3.zero;
public SerializableVector3 Rotation { get; set; } = SerializableVector3.Zero;
public SerializableVector3 Rotation { get; private set; } = SerializableVector3.Zero;

/// <summary>
/// Gets or sets the workstation's scale.
/// Gets the workstation's scale.
/// </summary>
// public Vector3 Scale { get; set; } = Vector3.one;
public SerializableVector3 Scale { get; set; } = SerializableVector3.One;
public SerializableVector3 Scale { get; private set; } = SerializableVector3.One;

/// <summary>
/// Gets or sets the <see cref="Exiled.API.Enums.RoomType"/> which is used to determine the spawn pos and rotation of the object.
/// Gets the <see cref="Exiled.API.Enums.RoomType"/> which is used to determine the spawn pos and rotation of the object.
/// </summary>
public RoomType RoomType { get; set; } = RoomType.Unknown;
public RoomType RoomType { get; private set; } = RoomType.Unknown;
}
}
5 changes: 4 additions & 1 deletion MapEditorReborn/Commands/ModifyingCommands/Position.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s

case "BRING":
{
newPosition = player.Position + (Vector3.down * 1.33f);
newPosition = player.Position;

if (gameObject.name.Contains("Door"))
newPosition += Vector3.down * 1.33f;

NetworkServer.UnSpawn(gameObject);
gameObject.transform.position = newPosition;
Expand Down
7 changes: 7 additions & 0 deletions MapEditorReborn/Commands/UtilityCommands/ShowIndicators.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s

Handler.SpawnPickupIndicator(gameObject.transform.position, gameObject.transform.rotation, itemSpawnPointComponent.ItemName, gameObject);

break;
}

case "RagdollSpawnPointObject(Clone)":
{
Handler.SpawnDummyIndicator(gameObject.transform.position, gameObject.GetComponent<RagdollObjectComponent>().RagdollRoleType, gameObject);

break;
}
}
Expand Down
Loading

0 comments on commit e982220

Please sign in to comment.