TechbloxModdingAPI/GamecraftModdingAPI/Blocks/SpawnPoint.cs
NorbiPeti 7336fe8353 Add support for initializing blocks with properties
Newly created blocks use the initializer to set properties, allowing the user to set per-block properties
2020-07-24 11:11:52 -04:00

78 lines
2 KiB
C#

using System;
using RobocraftX.Blocks;
using RobocraftX.Common;
using Gamecraft.CharacterVulnerability;
using Svelto.ECS;
using Unity.Mathematics;
using GamecraftModdingAPI;
using GamecraftModdingAPI.Utility;
namespace GamecraftModdingAPI.Blocks
{
public class SpawnPoint : Block
{
public SpawnPoint(EGID id) : base(id)
{
}
public SpawnPoint(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_SPAWNPOINT_BLOCK_GROUP))
{
}
// custom spawn point properties
/// <summary>
/// The lives the player spawns in with.
/// </summary>
public uint Lives
{
get => BlockEngine.GetBlockInfo(this, (SpawnPointStatsEntityStruct st) => st.lives);
set
{
BlockEngine.SetBlockInfo(this, (ref SpawnPointStatsEntityStruct st, uint val) => st.lives = val, value);
}
}
/// <summary>
/// Whether the spawned player can take damage.
/// </summary>
public bool Damageable
{
get => BlockEngine.GetBlockInfo(this, (SpawnPointStatsEntityStruct st) => st.canTakeDamage);
set
{
BlockEngine.SetBlockInfo(this, (ref SpawnPointStatsEntityStruct st, bool val) => st.canTakeDamage = val, value);
}
}
/// <summary>
/// Whether the game over screen will be displayed
/// </summary>
public bool GameOverEnabled
{
get => BlockEngine.GetBlockInfo(this, (SpawnPointStatsEntityStruct st) => st.gameOverScreen);
set
{
BlockEngine.SetBlockInfo(this, (ref SpawnPointStatsEntityStruct st, bool val) => st.gameOverScreen = val, value);
}
}
/// <summary>
/// The team id for players who spawn here.
/// </summary>
public byte Team
{
get => BlockEngine.GetBlockInfo(this, (SpawnPointIdsEntityStruct st) => st.teamId);
set
{
BlockEngine.SetBlockInfo(this, (ref SpawnPointIdsEntityStruct st, byte val) => st.teamId = val, value);
}
}
}
}