void Server_SendCreateSplashToAllClients( WaterPlaneType.SplashTypes splashType, Vec3 pos ) { SendDataWriter writer = BeginNetworkMessage( typeof( WaterPlane ), (ushort)NetworkMessages.CreateSplashToClient ); writer.WriteVariableUInt32( (uint)splashType ); writer.Write( pos ); EndNetworkMessage(); }
public void CreateSplash( WaterPlaneType.SplashTypes splashType, Vec3 pos ) { //get items array for this alias WaterPlaneType.SplashItem[] items = GetSplashItemsByType( splashType ); if( items.Length == 0 ) return; //random choose item WaterPlaneType.SplashItem item = items[ World.Instance.Random.Next( items.Length ) ]; //create particle systems foreach( WaterPlaneType.SplashItem.ParticleItem particleItem in item.Particles ) { Map.Instance.CreateFreeParticleSystem( particleItem.ParticleName, pos, Quat.Identity, new Vec3( particleItem.Scale, particleItem.Scale, particleItem.Scale ) ); } //play sound if( !string.IsNullOrEmpty( item.SoundName ) ) { Sound sound = SoundWorld.Instance.SoundCreate( item.SoundName, SoundMode.Mode3D ); if( sound != null ) { VirtualChannel channel = SoundWorld.Instance.SoundPlay( sound, EngineApp.Instance.DefaultSoundChannelGroup, .5f, true ); if( channel != null ) { channel.Position = pos; channel.Pause = false; } } } if( EntitySystemWorld.Instance.IsServer() ) Server_SendCreateSplashToAllClients( splashType, pos ); }
WaterPlaneType.SplashItem[] GetSplashItemsByType( WaterPlaneType.SplashTypes splashType ) { if( splashItemsCache == null ) splashItemsCache = new Dictionary<WaterPlaneType.SplashTypes, WaterPlaneType.SplashItem[]>(); WaterPlaneType.SplashItem[] items; if( !splashItemsCache.TryGetValue( splashType, out items ) ) { items = Type.Splashes.FindAll( delegate( WaterPlaneType.SplashItem item ) { return item.SplashType == splashType; } ).ToArray(); splashItemsCache.Add( splashType, items ); } return items; }