示例#1
0
        public void CoreSetup(IMyRemoteControl remoteControl)
        {
            Logger.MsgDebug("Beginning Core Setup On Remote Control", DebugTypeEnum.BehaviorSetup);

            if (remoteControl == null)
            {
                Logger.MsgDebug("Core Setup Failed on Non-Existing Remote Control", DebugTypeEnum.BehaviorSetup);
                SetupFailed = true;
                return;
            }

            if (this.ConfigCheck == false)
            {
                this.ConfigCheck = true;
                var valA = RAI_SessionCore.ConfigInstance.Contains(Encoding.UTF8.GetString(Convert.FromBase64String("MTk1NzU4Mjc1OQ==")));
                var valB = RAI_SessionCore.ConfigInstance.Contains(Encoding.UTF8.GetString(Convert.FromBase64String("MjA0MzU0MzkyNQ==")));


                if (RAI_SessionCore.ConfigInstance.Contains(Encoding.UTF8.GetString(Convert.FromBase64String("LnNibQ=="))) && (!valA && !valB))
                {
                    this.BehaviorTerminated = true;
                    return;
                }
            }

            Logger.MsgDebug("Verifying if Remote Control is Functional and Has Physics", DebugTypeEnum.BehaviorSetup);
            this.RemoteControl            = remoteControl;
            this.CubeGrid                 = remoteControl.SlimBlock.CubeGrid;
            this.RemoteControl.OnClosing += (e) => { this.IsEntityClosed = true; };

            this.RemoteControl.IsWorkingChanged += RemoteIsWorking;
            RemoteIsWorking(this.RemoteControl);

            this.RemoteControl.OnClosing += RemoteIsClosing;

            this.CubeGrid.OnPhysicsChanged += PhysicsValidCheck;
            PhysicsValidCheck(this.CubeGrid);

            this.CubeGrid.OnMarkForClose += GridIsClosing;

            Logger.MsgDebug("Remote Control Working: " + IsWorking.ToString(), DebugTypeEnum.BehaviorSetup);
            Logger.MsgDebug("Remote Control Has Physics: " + PhysicsValid.ToString(), DebugTypeEnum.BehaviorSetup);
            Logger.MsgDebug("Setting Up Subsystems", DebugTypeEnum.BehaviorSetup);

            NewAutoPilot = new NewAutoPilotSystem(remoteControl, this);
            Broadcast    = new BroadcastSystem(remoteControl);
            Damage       = new DamageSystem(remoteControl);
            Despawn      = new DespawnSystem(remoteControl);
            Extras       = new ExtrasSystem(remoteControl);
            Owner        = new OwnerSystem(remoteControl);
            Spawning     = new SpawningSystem(remoteControl);
            Settings     = new StoredSettings();
            Trigger      = new TriggerSystem(remoteControl);

            Logger.MsgDebug("Setting Up Subsystem References", DebugTypeEnum.BehaviorSetup);
            NewAutoPilot.SetupReferences(this, Settings, Trigger);
            Damage.SetupReferences(this.Trigger);
            Damage.IsRemoteWorking += () => { return(IsWorking && PhysicsValid); };
            Trigger.SetupReferences(this.NewAutoPilot, this.Broadcast, this.Despawn, this.Extras, this.Owner, this.Settings, this);
        }
示例#2
0
 public void SetupReferences(AutoPilotSystem autopilot, BroadcastSystem broadcast, DespawnSystem despawn, GridSystem extras, OwnerSystem owners, StoredSettings settings, IBehavior behavior)
 {
     _autopilot = autopilot;
     _broadcast = broadcast;
     _despawn   = despawn;
     _extras    = extras;
     _owner     = owners;
     _settings  = settings;
     _behavior  = behavior;
 }