Files
RAGECOOP-V/Client/Scripts/Sync/Entities/SyncedProp.cs

43 lines
1.1 KiB
C#
Raw Normal View History

2022-07-20 17:50:01 +08:00
using GTA;
2022-07-02 17:14:56 +08:00
namespace RageCoop.Client
{
/// <summary>
/// Synchronized prop, mostly owned by server
/// </summary>
public class SyncedProp : SyncedEntity
{
internal SyncedProp(int id)
{
2022-09-06 21:46:35 +08:00
ID = id;
2022-07-02 17:14:56 +08:00
}
/// <summary>
/// The real entity
/// </summary>
public Prop MainProp { get; set; }
2022-07-20 17:50:01 +08:00
internal new int OwnerID
{
get
2022-07-02 17:14:56 +08:00
{
// alwayse owned by server
return 0;
2022-07-20 17:50:01 +08:00
}
}
2022-07-02 17:14:56 +08:00
internal override void Update()
{
if (!NeedUpdate) { return; }
2022-10-09 11:15:09 +08:00
if (!Model.IsLoaded) { Model.Request(); return; }
2022-09-06 21:46:35 +08:00
if (MainProp == null || !MainProp.Exists())
2022-07-02 17:14:56 +08:00
{
2022-09-06 21:46:35 +08:00
MainProp = World.CreateProp(Model, Position, Rotation, false, false);
MainProp.IsInvincible = true;
2022-07-02 17:14:56 +08:00
}
2022-09-06 21:46:35 +08:00
MainProp.Position = Position;
MainProp.Rotation = Rotation;
2022-07-02 17:14:56 +08:00
MainProp.SetFrozen(true);
2022-09-06 21:46:35 +08:00
LastUpdated = Main.Ticked;
2022-07-02 17:14:56 +08:00
}
}
}