Beispiel #1
0
        public static void PlaySound3D(SoundDefinition sound, BaseVob vob, float range = 3000, float volume = 1.0f)
        {
            if (sound == null)
            {
                throw new ArgumentNullException("Sound is null!");
            }
            if (vob == null)
            {
                throw new ArgumentNullException("Vob is null!");
            }

            if (!CanPlay(sound)) // don't play too many sounds at once
            {
                return;
            }

            Logger.Log("PlayVobSound: " + sound.Name);
            var param = zTSound3DParams.Create();

            param.Volume    = volume;
            param.Radius    = range;
            param.Reverb    = 0.15f;
            param.IsAmbient = true;
            int idPtr = Process.Alloc(4).ToInt32();

            Process.Write(idPtr, zCSndSys_MSS.PlaySound3D(sound.zSFX, vob.gVob, 0, param));

            vobSounds.Add(new ActiveSound(idPtr, param, sound));
        }
Beispiel #2
0
        public void SetGuideCommand(GuideCmd cmd)
        {
            if (this.currentCmd == cmd)
            {
                return;
            }

            if (this.currentCmd is TargetCmd)
            {
                BaseVob target = ((TargetCmd)this.currentCmd).Target;
                target.OnDespawn -= OnTargetDespawn;
                if (this.guide != null)
                {
                    this.guide.RemoveGuideTarget(target);
                }
            }
            if (cmd is TargetCmd)
            {
                BaseVob target = ((TargetCmd)cmd).Target;
                target.OnDespawn += OnTargetDespawn;
                if (this.guide != null)
                {
                    this.guide.AddGuideTarget(target);
                }
            }

            if (this.guide != null)
            {
                Messages.WriteGuidableCmd(this.guide, this, cmd);
            }

            this.currentCmd = cmd;
        }
Beispiel #3
0
 internal void RemoveVisibleVob(BaseVob vob)
 {
     visibleVobs.Remove(vob.ID);
     if (guideTargets.ContainsKey(vob.ID))
     {
         vob.targetOf.Add(this);
     }
 }
Beispiel #4
0
        public BaseVobInst()
        {
            this.baseInst = CreateVob();
            if (this.baseInst == null)
            {
                throw new NullReferenceException("BaseInst is null!");
            }

            pConstruct();
        }
Beispiel #5
0
 static void CheckSpawn(BaseVob vob, World world, Vec3f pos, Angles ang)
 {
     if (Commands.TryGetValue(vob.ID, out List <TargetCmd> cmdList))
     {
         for (int i = 0; i < cmdList.Count; i++)
         {
             cmdList[i].target = vob;
         }
     }
 }
Beispiel #6
0
 static void CheckDespawn(BaseVob vob)
 {
     if (Commands.TryGetValue(vob.ID, out List <TargetCmd> cmdList))
     {
         for (int i = 0; i < cmdList.Count; i++)
         {
             cmdList[i].sentDest = vob.Position;
             cmdList[i].target   = null;
         }
     }
 }
Beispiel #7
0
 internal void RemoveGuideTarget(BaseVob vob)
 {
     if (guideTargets.TryGetValue(vob.ID, out IntBox box))
     {
         box.Count--;
         if (box.Count == 0)
         {
             guideTargets.Remove(vob.ID);
             vob.targetOf.Remove(this);
         }
     }
 }
Beispiel #8
0
        public override void Stop(GuidedVob vob)
        {
            if (Commands.TryGetValue(targetID, out List <TargetCmd> cmdList))
            {
                cmdList.Remove(this);
                if (cmdList.Count == 0)
                {
                    Commands.Remove(targetID);
                }
            }

            this.target = null;
        }
Beispiel #9
0
 void Vob_OnSpawn(BaseVob vob, World world, Vec3f pos, Angles ang)
 {
     if (vob is NPC)
     {
         var gVob = ((NPC)vob).gVob;
         if (gVob != null && overlays != null)
         {
             for (int i = 0; i < overlays.Count; i++)
             {
                 gVob.ApplyOverlay(overlays[i].Name);
             }
         }
     }
 }
Beispiel #10
0
        public TargetCmd(BaseVob target, float distance)
        {
            if (target == null)
            {
                throw new ArgumentNullException("Target is null!");
            }
            if (!target.IsSpawned)
            {
                throw new ArgumentException("Target is not spawned!");
            }

            this.target   = target;
            this.distance = distance;
        }
Beispiel #11
0
 internal void AddGuideTarget(BaseVob vob)
 {
     if (guideTargets.TryGetValue(vob.ID, out IntBox box))
     {
         box.Count++;
     }
     else
     {
         guideTargets.Add(vob.ID, new IntBox());
         if (!visibleVobs.Contains(vob.ID))
         {
             vob.targetOf.Add(this);
         }
     }
 }
Beispiel #12
0
 void OnTargetDespawn(BaseVob vob)
 {
     RemoveGuideCommand();
 }
Beispiel #13
0
 public void RemoveDynVob(BaseVob vob)
 {
     dynVobs.Remove(ref vob.CellID);
 }
Beispiel #14
0
 public void AddDynVob(BaseVob vob)
 {
     dynVobs.Add(vob, ref vob.CellID);
 }
Beispiel #15
0
 internal void AddVisibleVob(BaseVob vob)
 {
     visibleVobs.Add(vob);
     vob.targetOf.Remove(this);
 }
Beispiel #16
0
 public TargetCmd GetTestCmd(BaseVob target)
 {
     return(null);
 }