Adds homes

This commit is contained in:
zontreck 2025-01-18 14:11:00 -07:00
parent 3f1ce790d9
commit d5dc0d5892
5 changed files with 184 additions and 4 deletions

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Runtime.ConstrainedExecution;
using Vintagestory.API.Common;
using Vintagestory.API.Common.Entities;
using Vintagestory.API.MathTools;
@ -8,7 +9,7 @@ using Vintagestory.GameContent;
namespace AriasServerUtils
{
[Serializable]
public class PlayerPosition
public class PlayerPosition : ICloneable
{
public int X { get; set; } = 0;
public int Y { get; set; } = 0;
@ -16,12 +17,27 @@ namespace AriasServerUtils
public int Dimension { get; set; } = 0;
public float Yaw { get; set; } = 0.0f;
public float Pitch { get; set; } = 0.0f;
public readonly PlayerPosition ZERO = new(0, 0, 0, 0, 0.0f, 0.0f);
public PlayerPosition() { }
internal PlayerPosition(int x, int y, int z, int dim, float yaw, float pitch)
{
this.X = x;
this.Y = y;
this.Z = z;
this.Dimension = dim;
this.Yaw = yaw;
this.Pitch = pitch;
}
public void Merge(Entity entity)
{
entity.TeleportTo(new BlockPos(X, Y, Z, Dimension));
entity.Pos.SetYaw(Yaw);
entity.Pos.Pitch = Pitch;
}
@ -41,13 +57,46 @@ namespace AriasServerUtils
pos.Dimension = playerPos.dimension;
pos.Yaw = entity.Pos.Yaw;
pos.Pitch = entity.Pos.Pitch;
return pos;
}
public object Clone()
{
return new PlayerPosition(this.X, this.Y, this.Z, this.Dimension, this.Yaw, this.Pitch);
}
}
public class PlayerInventory
{
public List<ItemStack> Items = new List<ItemStack>();
}
/// <summary>
/// This class creates a simple storage for all memory within this mod
/// </summary>
[Serializable]
public class PlayerStorage
{
public Dictionary<string, Home> Homes = new Dictionary<string, Home>();
}
/// <summary>
/// This class represents a single home object
/// </summary>
[Serializable]
public class Home
{
public PlayerPosition Location { get; set; }
public static Home MakeHome(Entity player, string homeName)
{
Home home = new Home();
home.Location = PlayerPosition.from(player);
return home;
}
}
}