Exemplo n.º 1
0
        internal void ClientUpdate(Weapon w, TransferTarget tData)
        {
            MyEntity targetEntity = null;

            if (tData.EntityId <= 0 || MyEntities.TryGetEntityById(tData.EntityId, out targetEntity, true))
            {
                Entity = targetEntity;

                if (tData.EntityId == 0)
                {
                    w.Target.Reset(w.System.Session.Tick, States.ServerReset);
                }
                else
                {
                    StateChange(true, tData.EntityId == -2 ? States.Fake : States.Acquired);

                    if (w.Target.IsProjectile)
                    {
                        GridAi.TargetType targetType;
                        GridAi.AcquireProjectile(w, out targetType);

                        if (targetType == GridAi.TargetType.None)
                        {
                            if (w.NewTarget.CurrentState != States.NoTargetsSeen)
                            {
                                w.NewTarget.Reset(w.Comp.Session.Tick, States.NoTargetsSeen);
                            }
                            if (w.Target.CurrentState != States.NoTargetsSeen)
                            {
                                w.Target.Reset(w.Comp.Session.Tick, States.NoTargetsSeen, !w.Comp.Data.Repo.Base.State.TrackingReticle);
                            }
                        }
                    }
                }
                w.TargetData.WeaponRandom.AcquireCurrentCounter = w.TargetData.WeaponRandom.AcquireTmpCounter;
                w.TargetData.WeaponRandom.AcquireRandom         = new Random(w.TargetData.WeaponRandom.CurrentSeed);
                ClientDirty = false;

                //Log.Line($"UpdateTarget: id:{tData.EntityId}({TargetId}) - entity:{Entity != null}({targetEntity != null}) - state:{CurrentState}({PreviousState}) - hasTarget:{tData.EntityId != 0}({HasTarget})");
            }
        }
Exemplo n.º 2
0
        internal void ClientUpdate(Weapon w, TransferTarget tData)
        {
            MyEntity targetEntity = null;

            if (tData.EntityId <= 0 || MyEntities.TryGetEntityById(tData.EntityId, out targetEntity, true))
            {
                Entity = targetEntity;

                if (tData.EntityId == 0)
                {
                    w.Target.Reset(w.System.Session.Tick, States.ServerReset);
                }
                else
                {
                    StateChange(true, tData.EntityId == -2 ? States.Fake : States.Acquired);

                    if (w.Target.IsProjectile)
                    {
                        GridAi.TargetType targetType;
                        GridAi.AcquireProjectile(w, out targetType);

                        if (targetType == GridAi.TargetType.None)
                        {
                            if (w.NewTarget.CurrentState != States.NoTargetsSeen)
                            {
                                w.NewTarget.Reset(w.Comp.Session.Tick, States.NoTargetsSeen);
                            }

                            if (w.Target.CurrentState != States.NoTargetsSeen)
                            {
                                w.Target.Reset(w.Comp.Session.Tick, States.NoTargetsSeen, !w.Comp.Data.Repo.Base.State.TrackingReticle && w.Comp.Data.Repo.Base.Set.Overrides.Control != GroupOverrides.ControlModes.Painter);
                            }
                        }
                    }
                }
                w.TargetData.WeaponRandom.AcquireCurrentCounter = w.TargetData.WeaponRandom.AcquireTmpCounter;
                w.TargetData.WeaponRandom.AcquireRandom         = new Random(w.TargetData.WeaponRandom.CurrentSeed);
                ClientDirty = false;
            }
        }