public static void SV_StartSound(Single[] origin, edict_t entity, Int32 channel, Int32 soundindex, Single volume, Single attenuation, Single timeofs) { Int32 sendchan; Int32 flags; Int32 i; Int32 ent; Boolean use_phs; if (volume < 0 || volume > 1) { Com.Error(Defines.ERR_FATAL, "SV_StartSound: volume = " + volume); } if (attenuation < 0 || attenuation > 4) { Com.Error(Defines.ERR_FATAL, "SV_StartSound: attenuation = " + attenuation); } if (timeofs < 0 || timeofs > 0.255) { Com.Error(Defines.ERR_FATAL, "SV_StartSound: timeofs = " + timeofs); } ent = entity.index; if ((channel & 8) != 0) { use_phs = false; channel &= 7; } else { use_phs = true; } sendchan = (ent << 3) | (channel & 7); flags = 0; if (volume != Defines.DEFAULT_SOUND_PACKET_VOLUME) { flags |= Defines.SND_VOLUME; } if (attenuation != Defines.DEFAULT_SOUND_PACKET_ATTENUATION) { flags |= Defines.SND_ATTENUATION; } if ((entity.svflags & Defines.SVF_NOCLIENT) != 0 || (entity.solid == Defines.SOLID_BSP) || origin != null) { flags |= Defines.SND_POS; } flags |= Defines.SND_ENT; if (timeofs != 0) { flags |= Defines.SND_OFFSET; } if (origin == null) { origin = origin_v; if (entity.solid == Defines.SOLID_BSP) { for (i = 0; i < 3; i++) { origin_v[i] = entity.s.origin[i] + 0.5F * (entity.mins[i] + entity.maxs[i]); } } else { Math3D.VectorCopy(entity.s.origin, origin_v); } } MSG.WriteByte(SV_INIT.sv.multicast, Defines.svc_sound); MSG.WriteByte(SV_INIT.sv.multicast, flags); MSG.WriteByte(SV_INIT.sv.multicast, soundindex); if ((flags & Defines.SND_VOLUME) != 0) { MSG.WriteByte(SV_INIT.sv.multicast, volume * 255); } if ((flags & Defines.SND_ATTENUATION) != 0) { MSG.WriteByte(SV_INIT.sv.multicast, attenuation * 64); } if ((flags & Defines.SND_OFFSET) != 0) { MSG.WriteByte(SV_INIT.sv.multicast, timeofs * 1000); } if ((flags & Defines.SND_ENT) != 0) { MSG.WriteShort(SV_INIT.sv.multicast, sendchan); } if ((flags & Defines.SND_POS) != 0) { MSG.WritePos(SV_INIT.sv.multicast, origin); } if (attenuation == Defines.ATTN_NONE) { use_phs = false; } if ((channel & Defines.CHAN_RELIABLE) != 0) { if (use_phs) { SV_Multicast(origin, Defines.MULTICAST_PHS_R); } else { SV_Multicast(origin, Defines.MULTICAST_ALL_R); } } else { if (use_phs) { SV_Multicast(origin, Defines.MULTICAST_PHS); } else { SV_Multicast(origin, Defines.MULTICAST_ALL); } } }
public static void PF_WritePos(float[] pos) { MSG.WritePos(SV_INIT.sv.multicast, pos); }