void Fire() { if (!Visible) { return; } if (fireworkBulletType == null) { return; } Bullet bullet = (Bullet)Entities.Instance.Create(fireworkBulletType, Map.Instance); bullet.Position = GetInterpolatedPosition() + new Vec3(0, 0, .1f); EngineRandom random = World.Instance.Random; Quat rot = new Angles(random.NextFloatCenter() * 25, 90 + random.NextFloatCenter() * 25, 0).ToQuat(); bullet.Rotation = rot; bullet.PostCreate(); foreach (MapObjectAttachedObject attachedObject in bullet.AttachedObjects) { MapObjectAttachedRibbonTrail attachedRibbonTrail = attachedObject as MapObjectAttachedRibbonTrail; if (attachedRibbonTrail == null) { continue; } ColorValue color; switch (random.Next(4)) { case 0: color = new ColorValue(1, 0, 0); break; case 1: color = new ColorValue(0, 1, 0); break; case 2: color = new ColorValue(0, 0, 1); break; case 3: color = new ColorValue(1, 1, 0); break; default: color = new ColorValue(0, 0, 0); break; } if (attachedRibbonTrail.RibbonTrail != null) { attachedRibbonTrail.RibbonTrail.Chains[0].InitialColor = color; } } }
protected override void OnPostCreate(bool loaded) { base.OnPostCreate(loaded); current_gears = Type.CONF.SoundGears.Find(delegate(SSDCType.SSDC_CONF.SoundGear gear) { return(gear.Number == 0); }); if (EngineApp.Instance.ApplicationType != EngineApp.ApplicationTypes.ResourceEditor) { if (PhysicsModel == null) { Log.Error("Car: Physics model not exists."); return; } car_body = PhysicsModel.GetBody("chassis"); dmd_shape = car_body.GetShape("dmd"); if (car_body == null) { Log.Error("Car: \"chassis\" body not exists."); return; } if (dmd_shape == null) { Log.Error("Car: \"dmd\" shape not exists."); return; } attached_mesh = GetFirstAttachedObjectByAlias("dmd") as MapObjectAttachedMesh; if (attached_mesh == null) { Log.Error("Car: mesh by \"dmd\" alias not exists."); return; } else { mesh_name = this.Name; attached_mesh.MeshObject.Mesh.Save("Data\\" + mesh_name + ".mesh"); attached_mesh.MeshName = mesh_name + ".mesh"; mesh = attached_mesh.MeshObject.Mesh; if (Type.CONF.RandomMaterials.Any()) { attached_mesh.MeshObject.SetMaterialNameForAllSubObjects(Type.CONF.RandomMaterials[World.Instance.Random.Next(0, Type.CONF.RandomMaterials.Count)].Path); } } if (Type.CONF.Deformation) { ParsingMesh(); } } if (EntitySystemWorld.Instance.WorldSimulationType != WorldSimulationTypes.Editor) { SubscribeToTickEvent(); MapObjectAttachedObject[] ortbrake = GetAllAttachedObjectsByAlias("brake"); for (int i = 0; i < ortbrake.Length; i++) { MapObjectAttachedRibbonTrail rt = ortbrake[i] as MapObjectAttachedRibbonTrail; if (rt != null) { rtbrake.Add(rt.RibbonTrail); } } } if (car_body != null) { car_body.Collision += OnCollision; } }