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

45 lines
1.0 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>
2022-10-23 19:02:39 +08:00
/// Synchronized prop, mostly owned by server
2022-07-02 17:14:56 +08:00
/// </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
}
2022-10-23 19:02:39 +08:00
2022-07-02 17:14:56 +08:00
/// <summary>
2022-10-23 19:02:39 +08:00
/// The real entity
2022-07-02 17:14:56 +08:00
/// </summary>
public Prop MainProp { get; set; }
2022-10-23 19:02:39 +08:00
internal new int OwnerID =>
// alwayse owned by server
0;
internal override void Update()
2022-07-20 17:50:01 +08:00
{
2022-10-23 19:02:39 +08:00
if (!NeedUpdate) return;
if (!Model.IsLoaded)
2022-07-02 17:14:56 +08:00
{
2022-10-23 19:02:39 +08:00
Model.Request();
return;
2022-07-20 17:50:01 +08:00
}
2022-07-02 17:14:56 +08:00
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-10-23 19:02:39 +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);
2023-02-13 20:44:50 +08:00
LastUpdated = Ticked;
2022-07-02 17:14:56 +08:00
}
}
2022-10-23 19:02:39 +08:00
}