예제 #1
0
        public static VehicleEntity CreateNewVehicle(VehicleContext context, int entityId, VehicleAssetConfigItem configItem, Vector3 position,
                                                     Vector3 eulerRotAngle)
        {
            var vehicle = context.CreateEntity();

            vehicle.AddEntityKey(new EntityKey(entityId, (int)EEntityType.Vehicle));
            vehicle.AddVehicleType(configItem.Type);
            vehicle.AddVehicleAssetInfo(configItem.Id, (int)configItem.Type, configItem.BundleName, configItem.AssetName,
                                        configItem.TipName, configItem.PostureId, configItem.HasRadio,
                                        configItem.CameraAnchorOffset, configItem.CameraDistance, configItem.CameraRotationDamping);
            vehicle.AddVehicleDynamicData(position, eulerRotAngle);
            vehicle.AddPosition(Vector3.zero);
            vehicle.position.AlwaysEqual = true;

            vehicle.AddVehicleCmd();
            vehicle.AddVehicleCmdOwner(new VehicleCmdOwnerAdapter(vehicle));
            vehicle.AddVehicleSyncEvent(new Queue <IVehicleSyncEvent>());
            vehicle.AddVehicleCollisionDamage(new Dictionary <EntityKey, VehicleCollisionDamage>(new EntityKeyComparer()));
            return(vehicle);
        }