2021-09-11 09:15:36 -07:00
using UnityEngine ;
using System.Collections.Generic ;
using System ;
using Oxide.Core ;
using ProtoBuf ;
namespace Oxide.Plugins
{
[Info("AutoElevators", "bmgjet", "1.0.0")]
2021-09-11 17:02:25 -07:00
[Description("Replaces elevators placed in rust with with working one.")]
2021-09-11 09:15:36 -07:00
public class AutoElevators : RustPlugin
{
2021-09-13 01:18:11 -07:00
private static SaveData _data ; //Save Data for between server restarts
private const string USE_PERM = "AutoElevators.use" ; //Permission required for /elevator chat commands
public List < Esettings > ElevatorUp = new List < Esettings > ( ) ; //Local settings file same as saved data
public float ScanRadius = 0.8f ; //Radius to use when buttons scan for elevator.
2021-09-11 09:15:36 -07:00
2021-09-11 17:02:25 -07:00
class SaveData
{
public List < Esettings > ElevatorUp = new List < Esettings > ( ) ;
}
private void WriteSaveData ( ) = > Interface . Oxide . DataFileSystem . WriteObject ( Name , _data ) ;
2021-09-11 09:15:36 -07:00
private void Init ( )
{
permission . RegisterPermission ( USE_PERM , this ) ;
2021-09-11 17:02:25 -07:00
if ( ! Interface . Oxide . DataFileSystem . ExistsDatafile ( Name ) )
{
Interface . Oxide . DataFileSystem . GetDatafile ( Name ) . Save ( ) ;
}
_data = Interface . Oxide . DataFileSystem . ReadObject < SaveData > ( Name ) ;
if ( _data = = null )
{
WriteSaveData ( ) ;
}
2021-09-14 02:44:32 -07:00
}
void OnServerInitialized ( )
{
2021-09-13 01:18:11 -07:00
//Delay in loading data for when server restarts some times elevators wouldnt be fully spawned in.
2021-09-11 18:30:08 -07:00
timer . Once ( 5f , ( ) = >
{
2021-09-11 17:02:25 -07:00
ReloadData ( ) ;
} ) ;
2021-09-11 09:15:36 -07:00
}
2021-09-11 18:30:08 -07:00
void OnServerSave ( )
2021-09-14 02:44:32 -07:00
{
DoSave ( ) ;
}
void DoSave ( )
2021-09-11 18:30:08 -07:00
{
_data . ElevatorUp = ElevatorUp ;
WriteSaveData ( ) ;
}
2021-09-11 09:15:36 -07:00
2021-09-11 17:02:25 -07:00
void Unload ( )
2021-09-11 09:15:36 -07:00
{
2021-09-11 17:02:25 -07:00
ClearElevators ( ) ;
try
2021-09-11 09:15:36 -07:00
{
2021-09-14 02:44:32 -07:00
DoSave ( ) ;
2021-09-11 17:02:25 -07:00
_data = null ;
2021-09-11 09:15:36 -07:00
}
2021-09-11 17:02:25 -07:00
catch { }
}
public void ReloadData ( )
{
ClearElevators ( ) ;
2021-09-11 09:15:36 -07:00
//create new elevators
bool flag = false ;
List < uint > update = new List < uint > ( ) ;
foreach ( PrefabData pd in World . Serialization . world . prefabs )
{
if ( pd . id = = 3845190333 )
{
Elevator el = CreateElevator ( pd . position , pd . rotation ) ;
2021-09-11 17:02:25 -07:00
if ( el = = null )
2021-09-11 09:15:36 -07:00
{
2021-09-11 20:24:06 -07:00
Puts ( "Fault creating elevator!" ) ;
2021-09-11 09:15:36 -07:00
}
foreach ( Esettings es in _data . ElevatorUp )
{
//Check for settings
if ( es . pos = = el . transform . position )
{
2021-09-13 01:18:11 -07:00
//create with set settings
2021-09-11 09:15:36 -07:00
update . Add ( el . net . ID ) ;
2021-09-14 02:44:32 -07:00
_data . ElevatorUp . Add ( new Esettings ( el . transform . position , el . transform . rotation . eulerAngles , el . net . ID , es . Floors , es . ReturnTime , es . AutoReturn , es . Speed , es . Direction , es . Custompos ) ) ;
2021-09-11 09:15:36 -07:00
flag = true ;
break ;
}
}
if ( ! flag )
{
2021-09-13 01:18:11 -07:00
//create new with default settings
2021-09-14 02:44:32 -07:00
_data . ElevatorUp . Add ( new Esettings ( el . transform . position , el . transform . rotation . eulerAngles , el . net . ID ) ) ;
2021-09-11 09:15:36 -07:00
}
2021-09-11 20:24:06 -07:00
el . SendNetworkUpdateImmediate ( ) ;
2021-09-11 09:15:36 -07:00
}
}
2021-09-13 01:18:11 -07:00
//clean up old netids from last session
2021-09-11 09:15:36 -07:00
if ( flag )
{
int count = _data . ElevatorUp . Count ;
for ( int c = 0 ; c < count ; c + + )
{
if ( ! update . Contains ( _data . ElevatorUp [ c ] . netid ) )
{
_data . ElevatorUp . Remove ( _data . ElevatorUp [ c ] ) ;
c - - ;
count - - ;
}
}
}
Puts ( "ReloadData" ) ;
WriteSaveData ( ) ;
2021-09-13 01:18:11 -07:00
//sync save data to local data.
2021-09-11 09:15:36 -07:00
ElevatorUp = _data . ElevatorUp ;
}
2021-09-11 17:02:25 -07:00
void resetdata ( )
{
2021-09-13 01:18:11 -07:00
//Clears data for a fresh start/map
2021-09-11 17:02:25 -07:00
Puts ( "Resettings datafile" ) ;
2021-09-11 20:24:06 -07:00
ElevatorUp . Clear ( ) ;
2021-09-11 17:02:25 -07:00
_data . ElevatorUp . Clear ( ) ;
WriteSaveData ( ) ;
ReloadData ( ) ;
}
2021-09-11 09:15:36 -07:00
2021-09-11 17:02:25 -07:00
public void ClearElevators ( )
{
//Delete any exsisting elevators
2021-09-11 18:30:08 -07:00
int test = 0 ;
2021-09-11 17:02:25 -07:00
foreach ( BaseNetworkable bn in BaseNetworkable . serverEntities )
2021-09-11 09:15:36 -07:00
{
2021-09-11 17:02:25 -07:00
if ( bn . prefabID = = 3845190333 )
{
2021-09-11 18:30:08 -07:00
//Scan area to make sure not train entance
var hits = Physics . SphereCastAll ( bn . transform . position , 6f , Vector3 . down ) ;
bool train = false ;
foreach ( var hit in hits )
{
if ( hit . GetEntity ( ) ? . prefabID = = 1802909967 )
{
test + + ;
train = true ;
break ;
}
}
if ( ! train )
{
2021-09-13 01:18:11 -07:00
//remove elevator if not train entrance since will be replaced by plugin.
2021-09-13 01:00:10 -07:00
bn . Kill ( ) ;
2021-09-11 18:30:08 -07:00
}
2021-09-11 17:02:25 -07:00
}
2021-09-11 09:15:36 -07:00
}
2021-09-13 01:00:10 -07:00
Puts ( "Train Elevators Found " + test . ToString ( ) ) ;
2021-09-11 17:02:25 -07:00
}
2021-09-11 20:24:06 -07:00
private List < Elevator > FindElevator ( Vector3 pos , float radius , Vector3 dir )
2021-09-11 17:02:25 -07:00
{
2021-09-11 20:24:06 -07:00
var hits = Physics . SphereCastAll ( pos , radius , dir ) ;
2021-09-11 17:02:25 -07:00
var x = new List < Elevator > ( ) ;
foreach ( var hit in hits )
2021-09-11 09:15:36 -07:00
{
2021-09-11 17:02:25 -07:00
var entity = hit . GetEntity ( ) ? . GetComponent < Elevator > ( ) ;
if ( entity & & ! x . Contains ( entity ) )
x . Add ( entity ) ;
2021-09-11 09:15:36 -07:00
}
2021-09-11 17:02:25 -07:00
return x ;
}
2021-09-11 09:15:36 -07:00
2021-09-11 17:02:25 -07:00
public Elevator CreateElevator ( Vector3 pos , Vector3 rot )
{
//Recreate elevators that are workable
Elevator newElevator = GameManager . server . CreateEntity ( "assets/prefabs/deployable/elevator/static/elevator.static.prefab" , pos + new Vector3 ( 0 , - 1 , 0 ) , new Quaternion ( rot . x , rot . y , rot . z , 0 ) , true ) as Elevator ;
newElevator . Spawn ( ) ;
newElevator . SetFlag ( BaseEntity . Flags . Reserved1 , true , false , true ) ;
newElevator . SetFlag ( Elevator . Flag_HasPower , true ) ;
return newElevator ;
}
public Esettings FindServerElevator ( uint id )
2021-09-11 09:15:36 -07:00
{
2021-09-11 17:02:25 -07:00
foreach ( Esettings bn in ElevatorUp )
2021-09-11 09:15:36 -07:00
{
2021-09-11 17:02:25 -07:00
if ( bn . netid = = id )
2021-09-11 09:15:36 -07:00
{
2021-09-11 17:02:25 -07:00
return bn ;
2021-09-11 09:15:36 -07:00
}
}
2021-09-11 17:02:25 -07:00
return null ;
}
2021-09-11 20:24:06 -07:00
public int FindElevatorIndex ( uint id )
{
int index = 0 ;
foreach ( Esettings bn in ElevatorUp )
{
2021-09-13 01:00:10 -07:00
if ( bn . netid = = id )
2021-09-11 20:24:06 -07:00
{
return index ;
}
2021-09-11 21:19:31 -07:00
index + + ;
2021-09-11 20:24:06 -07:00
}
return - 1 ;
}
2021-09-11 17:02:25 -07:00
object OnElevatorMove ( Elevator e )
2021-09-11 20:24:06 -07:00
{
2021-09-13 01:18:11 -07:00
//Elevator buttons trigger this
2021-09-14 02:44:32 -07:00
if ( e . OwnerID = = 0 )
{
ElevatorLogic ( e ) ;
}
2021-09-11 20:24:06 -07:00
return null ;
}
2021-09-14 02:44:32 -07:00
object OnButtonPress ( PressButton button , BasePlayer player )
{
if ( button . OwnerID = = 0 ) //Faster exit so doesnt scan player placed buttons
{
for ( int i = 0 ; i < 2 ; i + + )
{
Vector3 dir ;
//Checks up and down path incase button is above or below elevator.
if ( i = = 0 )
{
dir = Vector3 . down ;
}
else
{
dir = Vector3 . up ;
}
List < Elevator > e = FindElevator ( button . transform . position , ScanRadius , dir ) ;
foreach ( Elevator elevator in e )
{
Esettings es = FindServerElevator ( elevator . net . ID ) ;
if ( es ! = null )
{
//Found elevator trigger it.
ElevatorLogic ( elevator , es ) ;
return null ;
}
}
}
}
return null ;
}
void ElevatorLogic ( Elevator e , Esettings ThisElevator = null )
2021-09-11 17:02:25 -07:00
{
2021-09-13 01:18:11 -07:00
//Check if its a plugin replaced elevator
2021-09-14 02:44:32 -07:00
if ( ThisElevator = = null )
{
ThisElevator = FindServerElevator ( e . net . ID ) ;
}
2021-09-11 17:02:25 -07:00
if ( ThisElevator ! = null )
2021-09-11 09:15:36 -07:00
{
2021-09-11 17:02:25 -07:00
//Change floors if it is
2021-09-13 01:18:11 -07:00
//Check if elevator already triggered
2021-09-14 02:44:32 -07:00
if ( ! ThisElevator . up )
2021-09-11 17:02:25 -07:00
{
GoToFloor ( ThisElevator . Floors , e , ThisElevator ) ;
}
else
{
2021-09-13 01:18:11 -07:00
//return to base height
2021-09-11 17:02:25 -07:00
GoToFloor ( 1 , e , ThisElevator ) ;
}
2021-09-11 09:15:36 -07:00
}
}
2021-09-14 02:44:32 -07:00
void GoToFloor ( int floor , Elevator e , Esettings eset )
2021-09-11 17:02:25 -07:00
{
2021-09-13 01:00:10 -07:00
if ( e . HasFlag ( BaseEntity . Flags . Busy ) )
{
2021-09-13 01:18:11 -07:00
//Already moving so ignore command
2021-09-13 01:00:10 -07:00
return ;
}
2021-09-13 01:18:11 -07:00
//Set elevator speed
e . LiftSpeedPerMetre = eset . Speed ;
//Set up base variables
2021-09-14 02:44:32 -07:00
Vector3 vector = new Vector3 ( 0 , 1 , 0 ) ;
2021-09-13 01:00:10 -07:00
float timeToTravel = 0f ;
2021-09-13 01:18:11 -07:00
2021-09-14 02:44:32 -07:00
switch ( eset . Direction )
2021-09-13 01:00:10 -07:00
{
2021-09-13 01:18:11 -07:00
//Up Down
2021-09-13 01:00:10 -07:00
case 0 :
vector = e . transform . InverseTransformPoint ( e . transform . position + new Vector3 ( 0 , floor , 0 ) ) ;
timeToTravel = e . TimeToTravelDistance ( Mathf . Abs ( e . liftEntity . transform . localPosition . y + vector . y ) ) ;
LeanTween . moveLocalY ( e . liftEntity . gameObject , vector . y , timeToTravel ) ;
break ;
2021-09-14 02:44:32 -07:00
//Forward Back
2021-09-13 01:00:10 -07:00
case 1 :
vector = e . transform . InverseTransformPoint ( e . transform . position + new Vector3 ( floor , 0 , 0 ) ) ;
timeToTravel = e . TimeToTravelDistance ( Mathf . Abs ( e . liftEntity . transform . localPosition . x + vector . x ) ) ;
LeanTween . moveLocalX ( e . liftEntity . gameObject , vector . x , timeToTravel ) ;
break ;
2021-09-14 02:44:32 -07:00
//Side To Side
2021-09-13 01:00:10 -07:00
case 2 :
vector = e . transform . InverseTransformPoint ( e . transform . position + new Vector3 ( 0 , 0 , floor ) ) ;
timeToTravel = e . TimeToTravelDistance ( Mathf . Abs ( e . liftEntity . transform . localPosition . z + vector . z ) ) ;
LeanTween . moveLocalZ ( e . liftEntity . gameObject , vector . z , timeToTravel ) ;
break ;
2021-09-14 02:44:32 -07:00
case 3 :
//Custom position
if ( ! eset . up )
{
vector = e . transform . InverseTransformPoint ( e . transform . position + eset . Custompos ) ;
}
timeToTravel = e . TimeToTravelDistance ( Vector3 . Distance ( e . transform . position , vector ) ) ;
LeanTween . moveLocal ( e . liftEntity . gameObject , vector , timeToTravel ) ;
break ;
case 4 :
//Rotate X
vector = e . transform . InverseTransformPoint ( e . transform . rotation . eulerAngles + new Vector3 ( floor , 0 , 0 ) ) ;
timeToTravel = e . TimeToTravelDistance ( Mathf . Abs ( e . liftEntity . transform . rotation . eulerAngles . x + vector . x ) ) ;
if ( ! eset . up )
{
LeanTween . rotateX ( e . liftEntity . gameObject , vector . x , timeToTravel ) ;
}
else
{
LeanTween . rotateX ( e . liftEntity . gameObject , 0 , timeToTravel ) ;
}
break ;
case 5 :
//Rotate Y
vector = e . transform . InverseTransformPoint ( e . transform . rotation . eulerAngles + new Vector3 ( 0 , floor , 0 ) ) ;
timeToTravel = e . TimeToTravelDistance ( Mathf . Abs ( e . liftEntity . transform . rotation . eulerAngles . y + vector . y ) ) ;
if ( ! eset . up )
{
LeanTween . rotateY ( e . liftEntity . gameObject , vector . y , timeToTravel ) ;
}
else
{
LeanTween . rotateY ( e . liftEntity . gameObject , 0 , timeToTravel ) ;
}
break ;
case 6 :
//Rotate Z
vector = e . transform . InverseTransformPoint ( e . transform . rotation . eulerAngles + new Vector3 ( 0 , 0 , floor ) ) ;
timeToTravel = e . TimeToTravelDistance ( Mathf . Abs ( e . liftEntity . transform . rotation . eulerAngles . z + vector . z ) ) ;
if ( ! eset . up )
{
LeanTween . rotateZ ( e . liftEntity . gameObject , vector . z , timeToTravel ) ;
}
else
{
LeanTween . rotateZ ( e . liftEntity . gameObject , 0 , timeToTravel ) ;
}
break ;
case 7 :
//Throw player off
vector = e . transform . InverseTransformPoint ( e . transform . position + new Vector3 ( floor , floor , floor ) ) ;
timeToTravel = e . TimeToTravelDistance ( Mathf . Abs ( e . liftEntity . transform . localPosition . y + vector . y ) ) ;
LeanTween . moveLocalY ( e . liftEntity . gameObject , vector . z , timeToTravel ) ;
if ( ! eset . up )
{
LeanTween . rotateZ ( e . liftEntity . gameObject , 180 , timeToTravel ) ;
}
else
{
LeanTween . rotateZ ( e . liftEntity . gameObject , 0 , timeToTravel ) ;
}
break ;
2021-09-13 01:00:10 -07:00
}
2021-09-11 17:02:25 -07:00
e . SendNetworkUpdateImmediate ( ) ;
2021-09-13 01:18:11 -07:00
//Set busy flag
2021-09-11 17:02:25 -07:00
e . SetFlag ( global :: BaseEntity . Flags . Busy , true , false , true ) ;
2021-09-13 01:18:11 -07:00
//set timer to disable busy flag
2021-09-11 17:02:25 -07:00
e . Invoke ( new Action ( e . ClearBusy ) , timeToTravel ) ;
2021-09-14 02:44:32 -07:00
eset . up = ! eset . up ;
2021-09-13 01:18:11 -07:00
//Set up auto return based on delay.
2021-09-11 17:02:25 -07:00
if ( eset . AutoReturn )
2021-09-11 09:15:36 -07:00
{
2021-09-14 02:44:32 -07:00
timer . Once ( eset . ReturnTime + timeToTravel , ( ) = >
2021-09-11 09:15:36 -07:00
{
2021-09-14 02:44:32 -07:00
if ( eset . up )
2021-09-11 09:15:36 -07:00
{
2021-09-11 17:02:25 -07:00
GoToFloor ( 1 , e , eset ) ;
2021-09-11 09:15:36 -07:00
}
2021-09-11 17:02:25 -07:00
} ) ;
2021-09-11 09:15:36 -07:00
}
2021-09-11 17:02:25 -07:00
}
2021-09-11 09:15:36 -07:00
2021-09-13 01:18:11 -07:00
//Chat setup commands
2021-09-11 21:19:31 -07:00
[ChatCommand("elevator")]
2021-09-11 20:24:06 -07:00
private void SetSettings ( BasePlayer player , string command , string [ ] args )
{
2021-09-11 21:19:31 -07:00
if ( player = = null | | ! player . IPlayer . HasPermission ( USE_PERM ) ) return ;
if ( args = = null | | args . Length = = 0 | | args . Length = = 1 | | args . Length > = 3 )
{
2021-09-14 02:44:32 -07:00
player . ChatMessage ( "Help:\r\nYou must provide settings such as\r\n/elevator arg value\r\nSettings:\r\nfloors int (use neg to go down)\r\nreturn bool (true/flase auto return)\r\ndelay int (sec before return)\r\nspeed float (speed elevator moves)\r\ndirection int (0 = y, 1 = x, 2 = z)\r\nposition f|f|f (Vector to move to)\r\npos get (prints out players vector)\r\nsave yes (saves elevator settings straight away)\r\nreset yes (resets all server elevators)" ) ;
2021-09-11 21:19:31 -07:00
return ;
}
2021-09-11 20:24:06 -07:00
if ( ElevatorUp . Count = = 0 )
{
player . ChatMessage ( "_data file not found" ) ;
return ;
}
2021-09-11 21:19:31 -07:00
if ( args [ 0 ] = = "reset" & & args [ 1 ] = = "yes" )
{
player . ChatMessage ( "Resetting Data" ) ;
resetdata ( ) ;
return ;
}
2021-09-13 01:00:10 -07:00
if ( args [ 0 ] = = "pos" & & args [ 1 ] = = "get" )
{
player . ChatMessage ( "You are currently @ " + player . transform . position . ToString ( ) ) ;
return ;
}
2021-09-14 02:44:32 -07:00
if ( args [ 0 ] = = "save" & & args [ 1 ] = = "yes" )
{
DoSave ( ) ;
player . ChatMessage ( "Settings Saved" ) ;
return ;
}
2021-09-11 21:19:31 -07:00
2021-09-14 02:44:32 -07:00
int index = - 1 ;
2021-09-11 21:19:31 -07:00
Elevator entity = null ;
List < Elevator > e = FindElevator ( player . transform . position , 0.8f , Vector3 . down ) ;
foreach ( Elevator elevator in e )
{
2021-09-11 20:24:06 -07:00
Esettings es = FindServerElevator ( elevator . net . ID ) ;
if ( es ! = null )
{
index = FindElevatorIndex ( elevator . net . ID ) ;
2021-09-11 21:19:31 -07:00
entity = elevator ;
2021-09-14 02:44:32 -07:00
if ( es . up )
{
player . ChatMessage ( "Elevator must be at its base height to change setting" ) ;
return ;
}
break ;
2021-09-11 20:24:06 -07:00
}
2021-09-11 21:19:31 -07:00
}
2021-09-14 02:44:32 -07:00
if ( entity = = null )
2021-09-11 21:19:31 -07:00
{
2021-09-14 02:44:32 -07:00
player . ChatMessage ( "No Elevator Found, Stand on it and look down" ) ;
return ;
}
2021-09-11 20:24:06 -07:00
if ( index > = ElevatorUp . Count | | index = = - 1 )
{
2021-09-11 21:19:31 -07:00
player . ChatMessage ( "Cant find index" ) ;
2021-09-11 20:24:06 -07:00
return ;
}
2021-09-11 21:19:31 -07:00
switch ( args [ 0 ] )
{
case "floors" :
try
{
2021-09-14 02:44:32 -07:00
int newfloors = int . Parse ( args [ 1 ] ) ;
2021-09-11 21:19:31 -07:00
if ( newfloors = = 1 | | newfloors = = 0 )
2021-09-11 17:02:25 -07:00
{
2021-09-11 21:19:31 -07:00
newfloors = 2 ;
2021-09-11 17:02:25 -07:00
}
2021-09-11 21:19:31 -07:00
ElevatorUp [ index ] . Floors = newfloors ;
player . ChatMessage ( "Changed floors to " + newfloors . ToString ( ) ) ;
return ;
}
catch
{
player . ChatMessage ( "Must set a number as floors" ) ;
return ;
}
case "return" :
try
{
2021-09-14 02:44:32 -07:00
bool newreturn = Boolean . Parse ( args [ 1 ] ) ;
2021-09-11 21:19:31 -07:00
ElevatorUp [ index ] . AutoReturn = newreturn ;
player . ChatMessage ( "Changed Auto return to " + newreturn . ToString ( ) ) ;
return ;
}
catch
{
player . ChatMessage ( "Must set true / false" ) ;
return ;
}
case "delay" :
try
{
2021-09-14 02:44:32 -07:00
int newdelay = int . Parse ( args [ 1 ] ) ;
2021-09-11 21:19:31 -07:00
if ( newdelay < 5 )
2021-09-11 20:24:06 -07:00
{
2021-09-11 21:19:31 -07:00
player . ChatMessage ( "Use a value greater than 5" ) ;
2021-09-11 20:24:06 -07:00
return ;
}
2021-09-11 21:19:31 -07:00
ElevatorUp [ index ] . ReturnTime = newdelay ;
player . ChatMessage ( "Changed Auto return delay to " + newdelay . ToString ( ) + " sec" ) ;
return ;
}
catch
{
player . ChatMessage ( "Must set a number as seconds of delay" ) ;
return ;
}
case "speed" :
try
{
2021-09-14 02:44:32 -07:00
float newspeed = ( float ) double . Parse ( args [ 1 ] ) ;
2021-09-11 21:19:31 -07:00
if ( newspeed < = 0 )
2021-09-11 20:24:06 -07:00
{
2021-09-11 21:19:31 -07:00
player . ChatMessage ( "Use a value greater than 1" ) ;
2021-09-11 20:24:06 -07:00
return ;
}
2021-09-11 21:19:31 -07:00
ElevatorUp [ index ] . Speed = newspeed ;
player . ChatMessage ( "Changed elevator speed to " + newspeed . ToString ( ) + " per m" ) ;
return ;
}
catch
{
player . ChatMessage ( "Must set a float as speed per m" ) ;
return ;
}
2021-09-13 01:00:10 -07:00
case "direction" :
try
{
2021-09-14 02:44:32 -07:00
int newdirection = int . Parse ( args [ 1 ] ) ;
if ( newdirection > = 0 & & newdirection < = 7 )
2021-09-13 01:00:10 -07:00
{
ElevatorUp [ index ] . Direction = newdirection ;
player . ChatMessage ( "Changed elevator direction" ) ;
return ;
}
2021-09-14 02:44:32 -07:00
player . ChatMessage ( "Use a value of 0-7" ) ;
2021-09-13 01:00:10 -07:00
return ;
}
catch
{
player . ChatMessage ( "Must set a int as direction 0 = y, 1 = x, 2 = z" ) ;
return ;
}
case "position" :
try
{
string [ ] customposition = args [ 1 ] . Split ( '|' ) ;
2021-09-14 02:44:32 -07:00
ElevatorUp [ index ] . Custompos = new Vector3 ( float . Parse ( customposition [ 0 ] ) , float . Parse ( customposition [ 1 ] ) , float . Parse ( customposition [ 2 ] ) ) ;
player . ChatMessage ( "Custom positions set" ) ;
2021-09-13 01:00:10 -07:00
return ;
}
catch
{
player . ChatMessage ( "Please provide a vector floats seperated by | such as x|y|z" ) ;
return ;
}
2021-09-11 09:15:36 -07:00
}
}
2021-09-11 17:02:25 -07:00
public class Esettings
2021-09-11 09:15:36 -07:00
{
2021-09-11 17:02:25 -07:00
public Esettings ( )
2021-09-11 09:15:36 -07:00
{
}
2021-09-11 17:02:25 -07:00
public Esettings ( Vector3 p , Vector3 r , uint n )
{
this . pos = p ;
this . rot = r ;
this . netid = n ;
this . Floors = 2 ;
this . ReturnTime = 60 ;
this . AutoReturn = true ;
2021-09-14 02:44:32 -07:00
this . Speed = 2f ;
2021-09-13 01:00:10 -07:00
this . Direction = 0 ;
this . Custompos = new Vector3 ( 0 , 0 , 0 ) ;
2021-09-14 02:44:32 -07:00
this . up = false ;
2021-09-11 17:02:25 -07:00
}
2021-09-13 01:00:10 -07:00
public Esettings ( Vector3 p , Vector3 r , uint n , int f , int rt , bool at , float s , int d , Vector3 c )
2021-09-11 17:02:25 -07:00
{
this . pos = p ;
this . rot = r ;
this . netid = n ;
this . Floors = f ;
this . ReturnTime = rt ;
this . AutoReturn = at ;
2021-09-11 20:24:06 -07:00
this . Speed = s ;
2021-09-13 01:00:10 -07:00
this . Direction = d ;
this . Custompos = c ;
2021-09-14 02:44:32 -07:00
this . up = false ;
2021-09-11 17:02:25 -07:00
}
public uint netid ;
public Vector3 pos ;
public Vector3 rot ;
public int Floors ;
public int ReturnTime ;
public bool AutoReturn ;
2021-09-11 20:24:06 -07:00
public float Speed ;
2021-09-13 01:00:10 -07:00
public int Direction ;
public Vector3 Custompos ;
2021-09-14 02:44:32 -07:00
public bool up ;
2021-09-11 09:15:36 -07:00
}
}
}