Ejemplo n.º 1
0
        public static SerializableVehicle Create(InteractableVehicle vehicle)
        {
            var result = new SerializableVehicle();

            result.Health        = vehicle.health;
            result.Fuel          = vehicle.fuel;
            result.BatteryCharge = vehicle.batteryCharge;
            result.VehicleId     = vehicle.id;
            result.TrunkSpace    = vehicle.trunkItems?.items?.Select(c => SerializableItem.CreateSerializableItem(vehicle.trunkItems.page, c))?.ToList() ?? new List <SerializableItem>();

            result.Tires = vehicle.tires?.Select(c => c.isAlive)?.ToArray() ?? new bool[0];

            if (BarricadeManager.tryGetPlant(vehicle.transform, out byte x, out byte y, out ushort plant, out var region))
            {
                foreach (var data in region.barricades)
                {
                    if (data.barricade.isDead)
                    {
                        continue;
                    }

                    var drop      = region.drops.FirstOrDefault(c => c.instanceID == data.instanceID);
                    var barricade = SerializableBarricade.Create(drop, data);
                    result.Barricades.Add(barricade);
                }
            }

            return(result);
        }
        public static SerializableBarricade Create(BarricadeDrop drop, BarricadeData data)
        {
            SerializableBarricade result = new SerializableBarricade();

            result.Position = new Vector3Wrapper(data.point);
            result.Rotation = new Vector3Wrapper(drop.model.transform.localEulerAngles);

            result.Owner      = data.owner;
            result.Group      = data.group;
            result.State      = data.barricade.state;
            result.ActiveDate = data.objActiveDate;
            result.Health     = data.barricade.health;
            result.Id         = data.barricade.id;

            return(result);
        }