Пример #1
0
        // Happens each time a progress is made
        public static void ProgressCallback()
        {
            PDAScanner.ScanTarget scanTarget = PDAScanner.scanTarget;
            if (scanTarget.techType == TechType.Player)
            {
                return;
            }

            if (scanTarget.isValid && scanTarget.progress > 0f && scanTarget.gameObject.TryGetComponent(out NitroxEntity nitroxEntity))
            {
                // Should always be the same for the same entity
                NitroxId       nitroxId = nitroxEntity.Id;
                DateTimeOffset Now      = DateTimeOffset.UtcNow;

                // Start a thread when a scanning period starts
                if (!ThrottlingEntries.TryGetValue(nitroxId, out ThrottledEntry throttledEntry))
                {
                    ThrottlingEntries.Add(nitroxId, throttledEntry = new ThrottledEntry(scanTarget.techType, nitroxId, new PDAScanner.Entry()
                    {
                        techType = scanTarget.techType, progress = scanTarget.progress
                    }));

                    throttledEntry.StartThrottler();
                }
                PDAScanner.Entry scannerEntry = throttledEntry.GetEntry();

                // Updating the progress throttling
                throttledEntry.Update(Now, null, scanTarget.progress);
                // Throttling the packet sending
                if (Now.ToUnixTimeMilliseconds() < throttledEntry.LatestPacketSendTime.ToUnixTimeMilliseconds() + PACKET_SENDING_RATE)
                {
                    return;
                }

                NitroxTechType nitroxTechType = new NitroxTechType(scanTarget.techType.ToString());
                // This should not occur all the time because it only takes effect one time per entity
                // Then it occurs when someone else already scanned the entity
                // Check if the entry is already in the partial list, and then, change the progress
                if (PDAManagerEntry.CachedEntries.TryGetValue(nitroxTechType, out PDAProgressEntry pdaProgressEntry))
                {
                    if (pdaProgressEntry.Entries.TryGetValue(nitroxId, out float progress))
                    {
                        pdaProgressEntry.Entries.Remove(nitroxId);
                        // We'd like the progress to not decrease when two people scan the same thing at the same time
                        if (scannerEntry.progress < progress)
                        {
                            PDAScanner.scanTarget.progress = progress;
                            scannerEntry.progress          = progress;
                        }
                        if (pdaProgressEntry.Entries.Count == 0)
                        {
                            PDAManagerEntry.CachedEntries.Remove(nitroxTechType);
                        }
                    }
                }

                throttledEntry.Update(Now, Now, scanTarget.progress);
                PDAManagerEntry.Progress(throttledEntry.GetEntry(), nitroxId);
            }
        }
Пример #2
0
 public PDAEntryProgress(NitroxTechType techType, float progress, int unlocked, NitroxId nitroxId)
 {
     TechType = techType;
     Progress = progress;
     Unlocked = unlocked;
     NitroxId = nitroxId;
 }
Пример #3
0
        }                                          // If it's the first time the player used that item type it send the techType, if not null.

        public PlayerHeldItemChanged(ushort playerId, NitroxId itemId, ChangeType type, NitroxTechType isFirstTime)
        {
            PlayerId    = playerId;
            ItemId      = itemId;
            Type        = type;
            IsFirstTime = isFirstTime;
        }
Пример #4
0
 public NeptuneRocketModel(NitroxTechType techType, NitroxId id, NitroxVector3 position, NitroxQuaternion rotation, List <InteractiveChildObjectIdentifier> interactiveChildIdentifiers, Optional <NitroxId> dockingBayId, string name, NitroxVector3[] hsb, float health)
     : base(techType, id, position, rotation, interactiveChildIdentifiers, dockingBayId, name, hsb, health)
 {
     CurrentStage  = 0;
     ElevatorUp    = false;
     ConstructorId = new NitroxId(); //The ID will be set forever and will be fetched once a rocket base platform starts (see Rocket_Start_Patch)
 }
 public LiveMixinHealthChanged(NitroxTechType techType, NitroxId id, float lifeChanged, float totalHealth)
 {
     TechType        = techType;
     Id              = id;
     LifeChanged     = lifeChanged;
     TotalHealth     = totalHealth;
     DamageTakenData = Optional.Empty;
 }
Пример #6
0
 public UweWorldEntity(NitroxTechType techType, NitroxVector3 scale, string classId, string slotType, int cellLevel)
 {
     TechType  = techType;
     Scale     = scale;
     ClassId   = classId;
     SlotType  = slotType;
     CellLevel = cellLevel;
 }
Пример #7
0
 public SeamothModulesAction(NitroxTechType techType, int slotID, NitroxId id, NitroxVector3 forward, NitroxQuaternion rotation)
 {
     TechType = techType;
     SlotID   = slotID;
     Id       = id;
     Forward  = forward;
     Rotation = rotation;
 }
Пример #8
0
 public DroppedItem(NitroxId id, Optional <NitroxId> waterParkId, NitroxTechType techType, NitroxVector3 itemPosition, NitroxQuaternion itemRotation, byte[] bytes)
 {
     Id           = id;
     WaterParkId  = waterParkId;
     ItemPosition = itemPosition;
     ItemRotation = itemRotation;
     TechType     = techType;
     Bytes        = bytes;
 }
Пример #9
0
        public void EntryProgressChanged(NitroxTechType techType, float progress, int unlocked)
        {
            if (!PartiallyUnlockedByTechType.TryGetValue(techType, out PDAEntry pdaEntry))
            {
                PartiallyUnlockedByTechType[techType] = pdaEntry = new PDAEntry(techType, progress, unlocked);
            }

            pdaEntry.Progress = progress;
            pdaEntry.Unlocked = unlocked;
        }
        public static void Prefix(QuickSlots __instance, int slotID, ref NitroxTechType __state)
        {
            InventoryItem item = ((InventoryItem[])bindingField.GetValue(__instance))[slotID];

            if (item == null)
            {
                return;
            }
            __state = Player.main.IsToolUsed(item.item.GetTechType()) ? item.item.GetTechType().ToDto() : null;
        }
Пример #11
0
 public CyclopsModel(NitroxTechType techType, NitroxId id, NitroxVector3 position, NitroxQuaternion rotation, List <InteractiveChildObjectIdentifier> interactiveChildIdentifiers, Optional <NitroxId> dockingBayId, string name, NitroxVector3[] hsb, float health)
     : base(techType, id, position, rotation, interactiveChildIdentifiers, dockingBayId, name, hsb, health)
 {
     FloodLightsOn    = true;
     InternalLightsOn = true;
     SilentRunningOn  = false;
     ShieldOn         = false;
     SonarOn          = false;
     EngineState      = false;
     EngineMode       = CyclopsMotorMode.CyclopsMotorModes.Standard;
 }
 public LiveMixinHealthChanged(NitroxTechType techType, NitroxId id, float lifeChanged, float totalHealth, NitroxVector3 position, ushort damageType, Optional <NitroxId> dealerId)
 {
     TechType        = techType;
     Id              = id;
     LifeChanged     = lifeChanged;
     TotalHealth     = totalHealth;
     DamageTakenData = new DamageTakenData
     {
         Position   = position,
         DamageType = damageType,
         DealerId   = dealerId
     };
 }
Пример #13
0
 public void UnlockedTechType(NitroxTechType techType)
 {
     PartiallyUnlockedByTechType.Remove(techType);
     CachedProgress.Remove(techType);
     if (!UnlockedTechTypes.Contains(techType))
     {
         UnlockedTechTypes.Add(techType);
     }
     else
     {
         Log.Debug($"There was an attempt of adding a duplicated entry in the UnlockedTechTypes: [{techType.Name}]");
     }
 }
        public static void Postfix(InventoryItem ____heldItem, NitroxTechType __state)
        {
            if (____heldItem == null)
            {
                return;
            }
            Pickupable pickupable = ____heldItem.item;
            NitroxId   itemId     = NitroxEntity.GetId(pickupable.gameObject);
            PlayerTool component  = pickupable.GetComponent <PlayerTool>();

            PlayerHeldItemChanged.ChangeType type = component ? PlayerHeldItemChanged.ChangeType.DRAW_AS_TOOL : PlayerHeldItemChanged.ChangeType.DRAW_AS_ITEM;
            player.BroadcastHeldItemChanged(itemId, type, __state);
        }
Пример #15
0
 public ConstructorBeginCrafting(NitroxId constructorId, NitroxId constructeditemId, NitroxTechType techType, float duration, List <InteractiveChildObjectIdentifier> interactiveChildIdentifiers, NitroxVector3 position, NitroxQuaternion rotation,
                                 string name, NitroxVector3[] hsb, float health)
 {
     ConstructorId               = constructorId;
     ConstructedItemId           = constructeditemId;
     TechType                    = techType;
     Duration                    = duration;
     InteractiveChildIdentifiers = interactiveChildIdentifiers;
     Position                    = position;
     Rotation                    = rotation;
     Name   = name;
     HSB    = hsb;
     Health = health;
 }
Пример #16
0
        public static VehicleModel BuildFrom(NitroxTechType techType, NitroxId constructedItemId, NitroxVector3 position, NitroxQuaternion rotation, List <InteractiveChildObjectIdentifier> interactiveChildIdentifiers, Optional <NitroxId> dockingBayId, string name, NitroxVector3[] hsb, float health)
        {
            switch (techType.ToUnity())
            {
            case TechType.Seamoth:
                return(new SeamothModel(techType, constructedItemId, position, rotation, interactiveChildIdentifiers, Optional.Empty, name, hsb, health));

            case TechType.Exosuit:
                return(new ExosuitModel(techType, constructedItemId, position, rotation, interactiveChildIdentifiers, Optional.Empty, name, hsb, health));

            case TechType.Cyclops:
                return(new CyclopsModel(techType, constructedItemId, position, rotation, interactiveChildIdentifiers, Optional.Empty, name, hsb, health));

            case TechType.RocketBase:
                return(null);

            default:
                throw new Exception($"Could not build from: {techType}");
            }
        }
Пример #17
0
 public FabricatorItemPickup(NitroxId fabricatorId, NitroxTechType techType)
 {
     FabricatorId = fabricatorId;
     TechType     = techType;
 }
Пример #18
0
 public ExosuitModel(NitroxTechType techType, NitroxId id, NitroxVector3 position, NitroxQuaternion rotation, List <InteractiveChildObjectIdentifier> interactiveChildIdentifiers, Optional <NitroxId> dockingBayId, string name, NitroxVector3[] hsb, float health)
     : base(techType, id, position, rotation, interactiveChildIdentifiers, dockingBayId, name, hsb, health)
 {
     LeftArmId  = new NitroxId();
     RightArmId = new NitroxId();
 }
Пример #19
0
 public static TechType ToUnity(this NitroxTechType v)
 {
     return((TechType)Enum.Parse(typeof(TechType), v.Name));
 }
Пример #20
0
 public KnownTechEntryAdd(NitroxTechType techType, bool verbose)
 {
     TechType = techType;
     Verbose  = verbose;
 }