1
Fork 0
mirror of https://github.com/thegeneralist01/Scene-Manager-DevRepo synced 2026-01-11 23:50:29 +01:00

Added Barrier object

This commit is contained in:
Rich Dunne 2021-05-01 13:11:33 -06:00
parent 0e79fd8be8
commit 93951b3e28
4 changed files with 70 additions and 84 deletions

View file

@ -1,26 +1,71 @@
using Rage;
using SceneManager.Menus;
using SceneManager.Utils;
using System.Xml.Serialization;
namespace SceneManager.Objects
{
[XmlRoot(ElementName = "Barrier", Namespace = "")]
public class Barrier // Change this and properties to Public for import/export
public class Barrier : Object // Change this and properties to Public for import/export
{
public Object Object { get; }
public Model @Model{ get; }
public Vector3 Position { get; }
public float Rotation { get; }
public bool Invincible { get; }
public Vector3 SpawnPosition { get; }
public float SpawnHeading { get; }
new public bool Invincible { get; }
public bool Immobile { get; }
public bool LightsEnabled { get; }
public int TextureVariation { get; }
internal Barrier(Object barrier, Vector3 barrierPosition, float barrierRotation, bool invincible, bool immobile)
internal Barrier(Object barrier, Vector3 barrierPosition, float barrierRotation, bool invincible, bool immobile, int textureVariation = 0, bool lightsEnabled = false) : base(barrier.Model, barrierPosition, barrierRotation)
{
Object = barrier;
@Model = barrier.Model;
Position = barrierPosition;
Rotation = barrierRotation;
SpawnPosition = barrierPosition;
SpawnHeading = barrierRotation;
Invincible = invincible;
IsInvincible = invincible;
Immobile = immobile;
TextureVariation = textureVariation;
LightsEnabled = lightsEnabled;
if(BarrierManager.PlaceholderBarrier)
{
SetPositionWithSnap(BarrierManager.PlaceholderBarrier.Position);
}
Rage.Native.NativeFunction.Natives.SET_ENTITY_DYNAMIC(this, true);
if (Invincible)
{
Rage.Native.NativeFunction.Natives.SET_DISABLE_FRAG_DAMAGE(this, true);
if (Model.Name != "prop_barrier_wat_03a")
{
Rage.Native.NativeFunction.Natives.SET_DISABLE_BREAKING(this, true);
}
}
IsPositionFrozen = Immobile;
if (Settings.EnableAdvancedBarricadeOptions)
{
SetAdvancedOptions();
}
}
private void SetAdvancedOptions()
{
Rage.Native.NativeFunction.Natives.x971DA0055324D033(this, TextureVariation);
if (LightsEnabled)
{
Rage.Native.NativeFunction.Natives.SET_ENTITY_LIGHTS(this, false);
}
else
{
Rage.Native.NativeFunction.Natives.SET_ENTITY_LIGHTS(this, true);
}
//Rage.Native.NativeFunction.Natives.SET_ENTITY_TRAFFICLIGHT_OVERRIDE(barrier, setBarrierTrafficLight.Index);
IsPositionFrozen = true;
GameFiber.Sleep(50);
if (this && !Immobile)
{
IsPositionFrozen = false;
}
}
}
}