public static SerializableBarricade Create(BarricadeDrop drop, BarricadeData data)
        {
            var barricade = new SerializableBarricade
            {
                Position = new SerializableVector3(data.point),
                Rotation = new SerializableVector3(drop.model.transform.localEulerAngles),
                Owner    = data.owner,
                Group    = data.@group,
                State    = data.barricade.state,
                Health   = data.barricade.health,
                ID       = data.barricade.id
            };

            return(barricade);
        }
Пример #2
0
        public static SerializableVehicle Create(InteractableVehicle vehicle)
        {
            var vehicleTurret = new List <byte[]>();

            if (vehicle.turrets != null && vehicle.turrets?.Length != 0)
            {
                byte index = 0;
                while (index < vehicle.turrets.Length)
                {
                    vehicleTurret.Add(vehicle.turrets[index].state);
                    index++;
                }
            }

            var result = new SerializableVehicle
            {
                Health        = vehicle.health,
                Fuel          = vehicle.fuel,
                BatteryCharge = vehicle.batteryCharge,
                ID            = vehicle.id,
                TrunkItems    =
                    vehicle.trunkItems?.items?.Select(c => SerializableItem.Create(vehicle.trunkItems.page, c)).ToList() ??
                    new List <SerializableItem>(),
                Tires   = vehicle.tires?.Select(c => c.isAlive)?.ToArray() ?? new bool[0],
                Turrets = vehicleTurret
            };

            if (BarricadeManager.tryGetPlant(vehicle.transform, out _, out _, out _, out var region))
            {
                foreach (var barricade in from data in region.barricades where !data.barricade.isDead let drop = region.drops.FirstOrDefault(c => c.instanceID == data.instanceID) select SerializableBarricade.Create(drop, data))
                {
                    result.Barricades.Add(barricade);
                }
            }

            return(result);
        }