コード例 #1
0
 static void Stop(TimedRocket __instance)
 {
     __instance.hasFired = false;
     __instance.SFX.Stop();
     __instance.flightSFX.Stop();
     __instance.StopSmokeTrail();
     __instance.StopAllCoroutines();
 }
コード例 #2
0
        IEnumerator Explode()
        {
            if (Exploding)
            {
                while (CountDownExplode >= 0)
                {
                    yield return(new WaitForFixedUpdate());

                    --CountDownExplode;
                    StartCoroutine(Explode());
                    yield break;
                }
                ECS = GameObject.Find("Exploding Cannonball Mod").GetComponent <ExplodingCannonballScript>();
                if (ECS.TypeOfExplosion == 1)
                {
                    GameObject explo = (GameObject)GameObject.Instantiate(PrefabMaster.BlockPrefabs[23].gameObject, this.transform.position, this.transform.rotation);
                    explo.transform.localScale = Vector3.one * 0.01f;
                    ExplodeOnCollideBlock ac = explo.GetComponent <ExplodeOnCollideBlock>();
                    ac.radius      = 7 * ECS.RangeMultiplierOfExplosion;
                    ac.power       = 2100f * ECS.PowerMultiplierOfExplosion;
                    ac.torquePower = 100000 * ECS.PowerMultiplierOfExplosion;
                    ac.upPower     = 0;
                    ac.Explodey();
                    explo.AddComponent <TimedSelfDestruct>();
                    Destroy(this.gameObject);
                }
                else if (ECS.TypeOfExplosion == 2)
                {
                    GameObject explo = (GameObject)GameObject.Instantiate(PrefabMaster.BlockPrefabs[54].gameObject, this.transform.position, this.transform.rotation);
                    explo.transform.localScale = Vector3.one * 0.01f;
                    ControllableBomb ac = explo.GetComponent <ControllableBomb>();
                    ac.radius      = 3 * ECS.RangeMultiplierOfExplosion;
                    ac.power       = 1500 * ECS.PowerMultiplierOfExplosion;
                    ac.randomDelay = 0.00001f;
                    ac.upPower     = 0f;
                    ac.StartCoroutine_Auto(ac.Explode());
                    explo.AddComponent <TimedSelfDestruct>();
                    Destroy(this.gameObject);
                }
                else if (ECS.TypeOfExplosion == 3)
                {
                    GameObject explo = (GameObject)GameObject.Instantiate(PrefabMaster.BlockPrefabs[59].gameObject, this.transform.position, this.transform.rotation);
                    explo.transform.localScale = Vector3.one * 0.01f;
                    TimedRocket ac = explo.GetComponent <TimedRocket>();
                    ac.SetSlip(Color.white);
                    ac.radius      = 3 * ECS.RangeMultiplierOfExplosion;
                    ac.power       = 1500 * ECS.PowerMultiplierOfExplosion;
                    ac.randomDelay = 0.000001f;
                    ac.upPower     = 0;
                    ac.StartCoroutine(ac.Explode(0.01f));
                    explo.AddComponent <TimedSelfDestruct>();
                    Destroy(this.gameObject);
                }
            }
        }
コード例 #3
0
 public void UpdateRocketFiredStatus(TimedRocket rocket)
 {
     if (playerGroupedRockets.TryGetValue(StatMaster.isMP ? PlayerMachine.GetLocal().Player.NetworkId : 0, out Dictionary <KeyCode, HashSet <TimedRocket> > groupedRockets))
     {
         RocketScript rocketScript = rocket.GetComponent <RocketScript>();
         if (rocketScript != null)
         {
             if (groupedRockets.TryGetValue(rocketScript.GroupFireKey.GetKey(0), out HashSet <TimedRocket> rockets))
             {
                 rockets.Remove(rocket);
             }
         }
     }
 }
コード例 #4
0
        private IEnumerator ReleaseGrabbers(TimedRocket rocket)
        {
            //if (rocket == null) yield return null;
            if (rocket.grabbers.Count > 0)
            {
                yield return(null);
            }

            List <JoinOnTriggerBlock> allGrabbers = new List <JoinOnTriggerBlock>(rocket.grabbers);

            foreach (var grabber in allGrabbers)
            {
                grabber?.OnKeyPressed();
            }
            yield return(null);
        }
コード例 #5
0
        public Target(Collider collider)
        {
            this.collider = collider;
            if (Enable)
            {
                this.transform = collider.transform;
                this.rigidbody = collider.GetComponentInAll <Rigidbody>();
                block          = collider.GetComponentInAll <BlockBehaviour>();
                entity         = collider.GetComponentInAll <GenericEntity>();
                fireTag        = collider.GetComponentInAll <FireTag>();
                rocket         = collider.GetComponentInAll <TimedRocket>();
                bomb           = collider.GetComponentInAll <ExplodeOnCollideBlock>();
                joint          = collider.GetComponentInAll <Joint>();

                RefreshWarningValue();
            }
        }
コード例 #6
0
            static void Postfix(TimedRocket __instance)
            {
                Properties[__instance] = new Property();
                __instance.CallPrivateMethod <MToggle>(
                    "AddToggle",
                    new Type[] { typeof(string), typeof(string), typeof(bool) },
                    new object[] { "Hold Mode", "holdmode", false }
                    ).Toggled += active => {
                    __instance.Sliders.Find(t => t.Key == "duration").DisplayInMapper = !(IsToggleModeActive(__instance) || active);
                };

                __instance.CallPrivateMethod <MToggle>(
                    "AddToggle",
                    new Type[] { typeof(string), typeof(string), typeof(bool) },
                    new object[] { "Toggle Mode", "togglemode", false }
                    ).Toggled += active => {
                    __instance.Sliders.Find(t => t.Key == "duration").DisplayInMapper = !(IsHoldModeActive(__instance) || active);
                };
            }
コード例 #7
0
        public IEnumerator LaunchRocketFromGroup(int id, KeyCode key)
        {
            launchStarted = true;
            float defaultDelay = 0.25f;

            if (playerGroupedRockets.TryGetValue(id, out Dictionary <KeyCode, HashSet <TimedRocket> > timedRocketDict))
            {
                if (timedRocketDict.TryGetValue(key, out HashSet <TimedRocket> timedRockets))
                {
                    if (timedRockets.Count > 0)
                    {
                        TimedRocket rocket = timedRockets.First();
                        timedRockets.Remove(rocket);
                        if (rocket != null)
                        {
                            RocketScript rocketScript = rocket.GetComponent <RocketScript>();
                            if (rocketScript != null)
                            {
                                rocket.Fire(0f);
                                rocket.hasFired    = true;
                                rocket.hasExploded = false;
                                if (rocketScript.autoGrabberRelease && rocket.grabbers.Count > 0)
                                {
                                    foreach (var grabber in rocket.grabbers)
                                    {
                                        grabber?.StartCoroutine(grabber.IEBreakJoint());
                                    }
                                }
                                defaultDelay = Mathf.Clamp(rocketScript.groupFireRate, 0.1f, 1f);
                            }
                        }
                    }
                }
            }
            for (int i = 0; i < defaultDelay * 100; i++)
            {
                yield return(new WaitForFixedUpdate());
            }

            launchStarted = false;
            yield return(null);
        }
コード例 #8
0
 protected override void Awake()
 {
     base.Awake();
     _RocketToggled = false;
     _Rocket        = GetComponent <TimedRocket>();
     Mod.AddToggle(_Rocket, "togglemode", "Toggle Mode", (active) => {
         if (active)
         {
             Mod.SetToggleValue(_Rocket, "holdmode", false);
         }
         _RefreshDurationSliderVisibility();
     });
     Mod.AddToggle(_Rocket, "holdmode", "Hold Mode", (active) => {
         if (active)
         {
             Mod.SetToggleValue(_Rocket, "togglemode", false);
         }
         _RefreshDurationSliderVisibility();
     });
     _RefreshDurationSliderVisibility();
 }
コード例 #9
0
        private IEnumerator ReleaseEjectors(TimedRocket rocket)
        {
            //if (rocket == null) yield return null;

            List <Joint> joinedBlocks = new List <Joint>(rocket.iJointTo);

            joinedBlocks.AddRange(rocket.jointsToMe);
            foreach (var joint in joinedBlocks)
            {
                if (joint == null)
                {
                    continue;
                }
                ExplosiveBolt bolt = joint.gameObject.GetComponent <ExplosiveBolt>();
                if (bolt == null)
                {
                    continue;
                }
                bolt?.Explode();
                break;
            }
            yield return(null);
        }
コード例 #10
0
 static void Postfix(TimedRocket __instance)
 {
     if (StatMaster.isSimulating)
     {
         if (IsHoldModeActive(__instance))
         {
             __instance.SetPrivateField <float>("timeFlown", 0);
             foreach (var key in __instance.Keys)
             {
                 if (key.IsReleased)
                 {
                     Stop(__instance);
                     break;
                 }
             }
         }
         else if (IsToggleModeActive(__instance))
         {
             __instance.SetPrivateField <float>("timeFlown", 0);
             foreach (var key in __instance.Keys)
             {
                 if (key.IsPressed)
                 {
                     if (Properties[__instance].State == 0)
                     {
                         Properties[__instance].State = 1;
                     }
                     else if (__instance.hasFired)
                     {
                         Properties[__instance].State = 0;
                         Stop(__instance);
                     }
                 }
             }
         }
     }
 }
コード例 #11
0
        public MessageController()
        {
            //Initiating messages
            Messages.rocketFiredMsg = ModNetworking.CreateMessageType(DataType.Block);
            Messages.rocketTargetBlockBehaviourMsg = ModNetworking.CreateMessageType(DataType.Block, DataType.Block);
            Messages.rocketTargetEntityMsg         = ModNetworking.CreateMessageType(DataType.Entity, DataType.Block);
            Messages.rocketTargetNullMsg           = ModNetworking.CreateMessageType(DataType.Block);
            Messages.rocketRayToHostMsg            = ModNetworking.CreateMessageType(DataType.Vector3, DataType.Vector3, DataType.Block);
            Messages.rocketHighExploPosition       = ModNetworking.CreateMessageType(DataType.Vector3, DataType.Single);
            Messages.rocketLockOnMeMsg             = ModNetworking.CreateMessageType(DataType.Block, DataType.Integer);
            Messages.rocketLostTargetMsg           = ModNetworking.CreateMessageType(DataType.Block);

            //Initiating callbacks
            ModNetworking.Callbacks[Messages.rocketHighExploPosition] += (Message msg) =>
            {
                if (StatMaster.isClient)
                {
                    Vector3 position            = (Vector3)msg.GetData(0);
                    float   bombExplosiveCharge = (float)msg.GetData(1);
                    int     levelBombCategory   = 4;
                    int     levelBombID         = 5001;
                    float   radius      = 7f;
                    float   power       = 3600f;
                    float   torquePower = 100000f;
                    float   upPower     = 0.25f;
                    try
                    {
                        GameObject bomb = UnityEngine.Object.Instantiate(PrefabMaster.LevelPrefabs[levelBombCategory].GetValue(levelBombID).gameObject);
                        bomb.transform.position = position;
                        ExplodeOnCollide bombControl = bomb.GetComponent <ExplodeOnCollide>();
                        bomb.transform.localScale = Vector3.one * bombExplosiveCharge;
                        bombControl.radius        = radius * bombExplosiveCharge;
                        bombControl.power         = power * bombExplosiveCharge;
                        bombControl.torquePower   = torquePower * bombExplosiveCharge;
                        bombControl.upPower       = upPower;
                        bombControl.Explodey();
                    }
                    catch { }
                }
            };

            ModNetworking.Callbacks[Messages.rocketFiredMsg] += (Message msg) =>
            {
                Block       rocketBlock = (Block)msg.GetData(0);
                TimedRocket rocket      = rocketBlock.GameObject.GetComponent <TimedRocket>();
                RocketsController.Instance.UpdateRocketFiredStatus(rocket);
            };

            ModNetworking.Callbacks[Messages.rocketTargetBlockBehaviourMsg] += (Message msg) =>
            {
#if DEBUG
                Debug.Log("Receive block target");
#endif
                Block        rocketBlock = (Block)msg.GetData(1);
                RocketScript rocket      = rocketBlock.GameObject.GetComponent <RocketScript>();
                rocket.target         = ((Block)msg.GetData(0)).GameObject.transform;
                rocket.targetCollider = rocket.target.gameObject.GetComponentInChildren <Collider>(true);
            };

            ModNetworking.Callbacks[Messages.rocketTargetEntityMsg] += (Message msg) =>
            {
#if DEBUG
                Debug.Log("Receive entity target");
#endif
                Block        rocketBlock = (Block)msg.GetData(1);
                RocketScript rocket      = rocketBlock.GameObject.GetComponent <RocketScript>();
                rocket.target         = ((Entity)msg.GetData(0)).GameObject.transform;
                rocket.targetCollider = rocket.target.gameObject.GetComponentInChildren <Collider>(true);
            };

            ModNetworking.Callbacks[Messages.rocketTargetNullMsg] += (Message msg) =>
            {
#if DEBUG
                Debug.Log("Receive entity target");
#endif
                Block        rocketBlock = (Block)msg.GetData(0);
                RocketScript rocket      = rocketBlock.GameObject.GetComponent <RocketScript>();
                rocket.target         = null;
                rocket.targetCollider = null;
            };

            ModNetworking.Callbacks[Messages.rocketRayToHostMsg] += (Message msg) =>
            {
                Block        rocketBlock = (Block)msg.GetData(2);
                RocketScript rocket      = rocketBlock.GameObject.GetComponent <RocketScript>();
                rocket.rayFromClient         = new Ray((Vector3)msg.GetData(0), (Vector3)msg.GetData(1));
                rocket.activeGuide           = false;
                rocket.receivedRayFromClient = true;
            };

            ModNetworking.Callbacks[Messages.rocketLockOnMeMsg] += (Message msg) =>
            {
                Block rocket          = (Block)msg.GetData(0);
                int   targetMachineID = (int)msg.GetData(1);
                RocketsController.Instance.UpdateRocketTarget(rocket.InternalObject, targetMachineID);
            };
            ModNetworking.Callbacks[Messages.rocketLostTargetMsg] += (Message msg) =>
            {
                Block rocket = (Block)msg.GetData(0);
                RocketsController.Instance.RemoveRocketTarget(rocket.InternalObject);
            };
        }
コード例 #12
0
ファイル: Rocket.cs プロジェクト: yut23/LenchScripterMod
 /// <summary>
 /// Creates a Block handler.
 /// </summary>
 /// <param name="bb">BlockBehaviour object.</param>
 public Rocket(BlockBehaviour bb) : base(bb)
 {
     tr = bb.GetComponent <TimedRocket>();
 }
コード例 #13
0
 static bool IsHoldModeActive(TimedRocket block)
 {
     return(block.Toggles.Find(t => t.Key == "holdmode").IsActive);
 }
コード例 #14
0
        protected override void SafeAwake()
        {
            //Key mapper setup
            GuidedRocketToggle          = AddToggle("追踪目标", "TrackingRocket", guidedRocketActivated);
            GuidedRocketToggle.Toggled += (bool value) =>
            {
                guidedRocketActivated = RecordTargetToggle.DisplayInMapper = GuidedRocketTorqueSlider.DisplayInMapper = ProximityFuzeToggle.DisplayInMapper = LockTargetKey.DisplayInMapper = ActiveGuideRocketKey.DisplayInMapper = ActiveGuideRocketSearchAngleSlider.DisplayInMapper = GuideDelaySlider.DisplayInMapper = value;
                ChangedProperties();
            };
            BlockDataLoadEvent += (XDataHolder BlockData) => { guidedRocketActivated = GuidedRocketToggle.IsActive; };

            RecordTargetToggle          = AddToggle("记录目标", "RecordTarget", recordTarget);
            RecordTargetToggle.Toggled += (bool value) =>
            {
                recordTarget = value;
                ChangedProperties();
            };
            BlockDataLoadEvent += (XDataHolder BlockData) => { recordTarget = RecordTargetToggle.IsActive; };

            ProximityFuzeToggle          = AddToggle("近炸", "ProximityFuze", proximityFuzeActivated);
            ProximityFuzeToggle.Toggled += (bool value) =>
            {
                proximityFuzeActivated = ProximityFuzeRangeSlider.DisplayInMapper = ProximityFuzeAngleSlider.DisplayInMapper = value;
                ChangedProperties();
            };
            BlockDataLoadEvent += (XDataHolder BlockData) => { proximityFuzeActivated = ProximityFuzeToggle.IsActive; };

            HighExploToggle          = AddToggle("高爆", "HighExplo", highExploActivated);
            HighExploToggle.Toggled += (bool value) =>
            {
                highExploActivated = value;
                ChangedProperties();
            };
            BlockDataLoadEvent += (XDataHolder BlockData) => { highExploActivated = HighExploToggle.IsActive; };

            ActiveGuideRocketSearchAngleSlider = AddSlider("搜索角度", "searchAngle", searchAngle, 0, 90, false);
            ActiveGuideRocketSearchAngleSlider.ValueChanged += (float value) => { searchAngle = value; ChangedProperties(); };
            BlockDataLoadEvent += (XDataHolder BlockData) => { searchAngle = ActiveGuideRocketSearchAngleSlider.Value; };

            ProximityFuzeRangeSlider = AddSlider("近炸距离", "closeRange", proximityRange, 0, 10, false);
            ProximityFuzeRangeSlider.ValueChanged += (float value) => { proximityRange = value; ChangedProperties(); };
            BlockDataLoadEvent += (XDataHolder BlockData) => { proximityRange = ProximityFuzeRangeSlider.Value; };

            ProximityFuzeAngleSlider = AddSlider("近炸角度", "closeAngle", proximityAngle, 0, 90, false);
            ProximityFuzeAngleSlider.ValueChanged += (float value) => { proximityAngle = value; ChangedProperties(); };
            BlockDataLoadEvent += (XDataHolder BlockData) => { proximityAngle = ProximityFuzeAngleSlider.Value; };

            GuidedRocketTorqueSlider = AddSlider("火箭扭转力度", "torqueOnRocket", torque, 0, 100, true);
            GuidedRocketTorqueSlider.ValueChanged += (float value) => { torque = value; ChangedProperties(); };
            BlockDataLoadEvent += (XDataHolder BlockData) => { torque = GuidedRocketTorqueSlider.Value; };

            GuideDelaySlider = AddSlider("延迟追踪", "guideDelay", guideDelay, 0, 100, false);
            GuideDelaySlider.ValueChanged += (float value) => { guideDelay = value; ChangedProperties(); };
            BlockDataLoadEvent            += (XDataHolder BlockData) => { guideDelay = GuideDelaySlider.Value; };

            LockTargetKey = AddKey("锁定目标", "lockTarget", lockKeys);
            LockTargetKey.InvokeKeysChanged();

            ActiveGuideRocketKey = AddKey("主动/手动搜索切换", "ActiveSearchKey", activeGuideKeys);
            ActiveGuideRocketKey.InvokeKeysChanged();

            //Add reference to TimedRocket
            rocket          = gameObject.GetComponent <TimedRocket>();
            rocketRigidbody = gameObject.GetComponent <Rigidbody>();
            selfIndex       = transform.GetComponent <BlockBehaviour>().BuildIndex;


#if DEBUG
            ConsoleController.ShowMessage("火箭添加进阶属性");
#endif
        }
コード例 #15
0
        public override void SafeAwake()
        {
            //Key mapper setup
            //Menus
            SettingMenu = AddMenu("SettingType", 0, LanguageManager.Instance.CurrentLanguage.SettingType);

            RadarTypeMenu = AddMenu("Radar Type", 0, LanguageManager.Instance.CurrentLanguage.RadarType);

            //Toggles
            ShowRadarToggle = AddToggle(LanguageManager.Instance.CurrentLanguage.ShowRadar, "ShowRadar", false);

            ImpactFuzeToggle = AddToggle(LanguageManager.Instance.CurrentLanguage.ImpactFuze, "ImpactFuze", false);

            ProximityFuzeToggle = AddToggle(LanguageManager.Instance.CurrentLanguage.ProximityFuze, "ProximityFuze", false);

            StabilityToggle = AddToggle(LanguageManager.Instance.CurrentLanguage.RocketStability, "RocketStabilityOn", false);

            AutoEjectToggle = AddToggle(LanguageManager.Instance.CurrentLanguage.AutoRelease, "AutoGrabberRelease", false);

            NoSmokeToggle = AddToggle(LanguageManager.Instance.CurrentLanguage.NoSmoke, "NoSmoke", false);

            HighExploToggle = AddToggle(LanguageManager.Instance.CurrentLanguage.HighExplo, "HighExplo", false);

            ShowPredictionToggle = AddToggle(LanguageManager.Instance.CurrentLanguage.ShowProjectileInterception, "ShowPrediction", false);

            GuidedRocketToggle = AddToggle(LanguageManager.Instance.CurrentLanguage.TrackTarget, "TrackingRocket", false); //Keep this as the last toggle

            //Sliders
            ActiveGuideRocketSearchAngleSlider = AddSlider(LanguageManager.Instance.CurrentLanguage.SearchAngle, "searchAngle", 60f, 0, maxSearchAngleNormal);

            TorqueSlider = AddSlider(LanguageManager.Instance.CurrentLanguage.TorqueOnRocket, "torqueOnRocket", 100f, 0, 100f);

            GuideDelaySlider = AddSlider(LanguageManager.Instance.CurrentLanguage.GuideDelay, "guideDelay", 0f, 0, 2);

            //PredictionSlider = AddSlider(LanguageManager.Instance.CurrentLanguage.Prediction, "prediction", 10, 0, 50);

            ProximityFuzeRangeSlider = AddSlider(LanguageManager.Instance.CurrentLanguage.CloseRange, "closeRange", 0f, 0, 10f);

            GroupFireRateSlider = AddSlider(LanguageManager.Instance.CurrentLanguage.GroupFireRate, "groupFireRate", 0.25f, 0.1f, 1f);

            ProjectileSpeedSlider = AddSlider(LanguageManager.Instance.CurrentLanguage.ProjectileSpeed, "CannonBallSpeed", 1f, 0.1f, 1000f);

            DragSlider = AddSlider("炮弹阻力", "CannonBallDrag", 0.2f, 0f, 1f);

            //Keys
            LockTargetKey = AddKey(LanguageManager.Instance.CurrentLanguage.LockTarget, "lockTarget", KeyCode.Delete);

            GroupFireKey = AddKey(LanguageManager.Instance.CurrentLanguage.GroupedFire, "groupFire", KeyCode.None);

            ManualOverrideKey = AddKey(LanguageManager.Instance.CurrentLanguage.ManualOverride, "ActiveSearchKey", KeyCode.RightShift);

            SPTeamKey = AddKey(LanguageManager.Instance.CurrentLanguage.SinglePlayerTeam, "SinglePlayerTeam", KeyCode.None);

            //Add reference to TimedRocket
            rocket          = gameObject.GetComponent <TimedRocket>();
            rocketRigidbody = gameObject.GetComponent <Rigidbody>();

#if DEBUG
            ConsoleController.ShowMessage("火箭添加进阶属性");
#endif
        }