示例#1
0
 internal static void SetRange(CoreComponent comp)
 {
     foreach (var w in comp.Platform.Weapons)
     {
         w.UpdateWeaponRange();
     }
 }
示例#2
0
        internal static void ResetCompState(CoreComponent comp, long playerId, bool resetTarget, Dictionary <string, int> settings = null)
        {
            var o           = comp.Data.Repo.Base.Set.Overrides;
            var userControl = o.Control != GroupOverrides.ControlModes.Auto;

            if (userControl)
            {
                comp.Data.Repo.Base.State.PlayerId = playerId;
                comp.Data.Repo.Base.State.Control  = CompStateValues.ControlMode.Ui;
                if (settings != null)
                {
                    settings["ControlModes"] = (int)o.Control;
                }
                comp.Data.Repo.Base.State.TerminalActionSetter(comp, ShootActions.ShootOff);
            }
            else
            {
                comp.Data.Repo.Base.State.PlayerId = -1;
                comp.Data.Repo.Base.State.Control  = CompStateValues.ControlMode.None;
            }

            if (resetTarget)
            {
                ClearTargets(comp);
            }
        }
示例#3
0
        internal void CompChange(bool add, CoreComponent comp)
        {
            if (add)
            {
                if (WeaponsIdx.ContainsKey(comp))
                {
                    Log.Line($"CompAddFailed:<{comp.MyCube.EntityId}> - comp({comp.MyCube.DebugName}[{comp.MyCube.BlockDefinition.Id.SubtypeName}]) already existed in {MyGrid.DebugName}");
                    return;
                }

                if (comp.HasArmor)
                {
                    for (int i = 0; i < comp.Platform.Weapons.Length; i++)
                    {
                        var w = comp.Platform.Weapons[i];
                        if (w.System.Armor != WeaponDefinition.HardPointDef.HardwareDef.ArmorState.IsWeapon)
                        {
                            Armor.Add(w.Comp.MyCube, w);
                        }
                    }
                    Session.ArmorCubes.Add(comp.MyCube, comp);
                }
                WeaponsIdx.Add(comp, Weapons.Count);
                Weapons.Add(comp);
            }
            else
            {
                int idx;
                if (!WeaponsIdx.TryGetValue(comp, out idx))
                {
                    Log.Line($"CompRemoveFailed: <{comp.MyCube.EntityId}> - {Weapons.Count}[{WeaponsIdx.Count}]({WeaponBase.Count}) - {Weapons.Contains(comp)}[{Weapons.Count}] - {Session.GridTargetingAIs[comp.MyCube.CubeGrid].WeaponBase.ContainsKey(comp.MyCube)} - {Session.GridTargetingAIs[comp.MyCube.CubeGrid].WeaponBase.Count} ");
                    return;
                }

                if (comp.HasArmor)
                {
                    for (int i = 0; i < comp.Platform.Weapons.Length; i++)
                    {
                        var w = comp.Platform.Weapons[i];
                        if (w.System.Armor != WeaponDefinition.HardPointDef.HardwareDef.ArmorState.IsWeapon)
                        {
                            Armor.Remove(w.Comp.MyCube);
                        }
                    }
                    Session.ArmorCubes.Remove(comp.MyCube);
                }

                Weapons.RemoveAtFast(idx);
                if (idx < Weapons.Count)
                {
                    WeaponsIdx[Weapons[idx]] = idx;
                }

                //Session.IdToCompMap.Remove(comp.MyCube.EntityId);
                WeaponsIdx.Remove(comp);
            }
        }
示例#4
0
 private static void ClearTargets(CoreComponent comp)
 {
     for (int i = 0; i < comp.Platform.Weapons.Length; i++)
     {
         var weapon = comp.Platform.Weapons[i];
         if (weapon.Target.HasTarget)
         {
             comp.Platform.Weapons[i].Target.Reset(comp.Session.Tick, Target.States.ControlReset);
         }
     }
 }
示例#5
0
 internal static void RequestSetValue(CoreComponent comp, string setting, int value, long playerId)
 {
     if (comp.Session.IsServer)
     {
         SetValue(comp, setting, value, playerId);
     }
     else if (comp.Session.IsClient)
     {
         comp.Session.SendOverRidesClientComp(comp, setting, value);
     }
 }
示例#6
0
        internal static void SetRof(CoreComponent comp)
        {
            for (int i = 0; i < comp.Platform.Weapons.Length; i++)
            {
                var w = comp.Platform.Weapons[i];

                if (w.ActiveAmmoDef.ConsumableDef.Const.MustCharge)
                {
                    continue;
                }

                w.UpdateRof();
            }

            SetDps(comp);
        }
示例#7
0
        internal static void SetDps(CoreComponent comp, bool change = false)
        {
            if (comp == null || comp.Platform.State != CorePlatform.PlatformState.Ready)
            {
                return;
            }

            for (int i = 0; i < comp.Platform.Weapons.Length; i++)
            {
                var w = comp.Platform.Weapons[i];
                if (!change && (!w.ActiveAmmoDef.ConsumableDef.Const.IsBeamWeapon || w.ActiveAmmoDef.ConsumableDef.Const.MustCharge))
                {
                    continue;
                }
                comp.Session.FutureEvents.Schedule(w.SetWeaponDps, null, 1);
            }
        }
示例#8
0
        internal static void SetValue(CoreComponent comp, string setting, int v, long playerId)
        {
            var o            = comp.Data.Repo.Base.Set.Overrides;
            var enabled      = v > 0;
            var clearTargets = false;

            switch (setting)
            {
            case "MaxSize":
                o.MaxSize = v;
                break;

            case "MinSize":
                o.MinSize = v;
                break;

            case "SubSystems":
                o.SubSystem = (WeaponDefinition.TargetingDef.BlockTypes)v;
                break;

            case "MovementModes":
                o.MoveMode   = (GroupOverrides.MoveModes)v;
                clearTargets = true;
                break;

            case "ControlModes":
                o.Control    = (GroupOverrides.ControlModes)v;
                clearTargets = true;
                break;

            case "FocusSubSystem":
                o.FocusSubSystem = enabled;
                break;

            case "FocusTargets":
                o.FocusTargets = enabled;
                clearTargets   = true;
                break;

            case "Unowned":
                o.Unowned = enabled;
                break;

            case "Friendly":
                o.Friendly   = enabled;
                clearTargets = true;
                break;

            case "Meteors":
                o.Meteors = enabled;
                break;

            case "Grids":
                o.Grids = enabled;
                break;

            case "Biologicals":
                o.Biologicals = enabled;
                break;

            case "Projectiles":
                o.Projectiles = enabled;
                clearTargets  = true;
                break;

            case "Neutrals":
                o.Neutrals   = enabled;
                clearTargets = true;
                break;
            }

            ResetCompState(comp, playerId, clearTargets);

            if (comp.Session.MpActive)
            {
                comp.Session.SendCompBaseData(comp);
            }
        }