Beispiel #1
0
        private void AddWorldObjectInternal(WorldObject wo)
        {
            worldObjects[wo.Guid] = wo;

            wo.CurrentLandblock = this;

            if (wo.PhysicsObj == null)
            {
                wo.InitPhysicsObj();
            }

            if (wo.PhysicsObj.CurCell == null)
            {
                var success = wo.AddPhysicsObj();
                if (!success)
                {
                    log.Warn($"AddWorldObjectInternal: couldn't spawn {wo.Name}");
                    return;
                }
            }

            // if adding a player to this landblock,
            // tell them about other nearby objects
            if (wo is Player || wo is CombatPet)
            {
                var newlyVisible = wo.PhysicsObj.handle_visible_cells();
                wo.PhysicsObj.enqueue_objs(newlyVisible);
            }

            // broadcast to nearby players
            wo.NotifyPlayers();
        }
Beispiel #2
0
        public static bool EnterWorld(WorldObject wo)
        {
            // called by generators
            wo.InitPhysicsObj();

            var success = wo.AddPhysicsObj(new Position(wo.Location));

            if (success)
            {
                switch (GeneratorTickMode)
                {
                case GeneratorTickMode.Instances:
                    AddInstance(wo);
                    break;

                case GeneratorTickMode.Encounters:
                    AddEncounter(wo);
                    break;

                default:
                    Console.WriteLine($"Server.EnterWorld({wo.WeenieClassId} - {wo.Name}) - GeneratorTickMode.{GeneratorTickMode}");
                    break;
                }
            }

            return(success);
        }
Beispiel #3
0
        private bool AddWorldObjectInternal(WorldObject wo)
        {
            wo.CurrentLandblock = this;

            if (wo.PhysicsObj == null)
            {
                wo.InitPhysicsObj();
            }

            if (wo.PhysicsObj.CurCell == null)
            {
                var success = wo.AddPhysicsObj();
                if (!success)
                {
                    wo.CurrentLandblock = null;

                    if (wo.Generator != null)
                    {
                        log.Debug($"AddWorldObjectInternal: couldn't spawn 0x{wo.Guid}:{wo.Name} from generator {wo.Generator.WeenieClassId} - 0x{wo.Generator.Guid}:{wo.Generator.Name}");
                    }

                    else if (wo.ProjectileTarget == null)
                    {
                        log.Warn($"AddWorldObjectInternal: couldn't spawn 0x{wo.Guid}:{wo.Name}");
                    }

                    return(false);
                }
            }

            if (!worldObjects.ContainsKey(wo.Guid))
            {
                pendingAdditions[wo.Guid] = wo;
            }
            else
            {
                pendingRemovals.Remove(wo.Guid);
            }

            // broadcast to nearby players
            wo.NotifyPlayers();

            if (wo is Player player)
            {
                player.SetFogColor(FogColor);
            }

            return(true);
        }
Beispiel #4
0
        private bool AddWorldObjectInternal(WorldObject wo)
        {
            wo.CurrentLandblock = this;

            if (wo.PhysicsObj == null)
            {
                wo.InitPhysicsObj();
            }

            if (wo.PhysicsObj.CurCell == null)
            {
                var success = wo.AddPhysicsObj();
                if (!success)
                {
                    wo.CurrentLandblock = null;
                    if (wo.Generator != null)
                    {
                        log.Debug($"AddWorldObjectInternal: couldn't spawn 0x{wo.Guid}:{wo.Name} from generator {wo.Generator.WeenieClassId} - 0x{wo.Generator.Guid}:{wo.Generator.Name}");
                    }
                    else
                    {
                        log.Warn($"AddWorldObjectInternal: couldn't spawn 0x{wo.Guid}:{wo.Name}");
                    }
                    return(false);
                }
            }

            if (!worldObjects.ContainsKey(wo.Guid))
            {
                pendingAdditions[wo.Guid] = wo;
            }
            else
            {
                pendingRemovals.Remove(wo.Guid);
            }

            // if adding a player to this landblock,
            // tell them about other nearby objects
            if (wo is Player || wo is CombatPet)
            {
                var newlyVisible = wo.PhysicsObj.handle_visible_cells();
                wo.PhysicsObj.enqueue_objs(newlyVisible);
            }

            // broadcast to nearby players
            wo.NotifyPlayers();

            return(true);
        }
Beispiel #5
0
        private void AddWorldObjectInternal(WorldObject wo)
        {
            //Console.WriteLine($"AddWorldObjectInternal({wo.Name})");

            if (!worldObjects.ContainsKey(wo.Guid))
            {
                worldObjects[wo.Guid] = wo;
            }

            wo.SetParent(this);

            if (wo.PhysicsObj == null)
            {
                wo.InitPhysicsObj();
            }

            if (wo.PhysicsObj.CurCell == null)
            {
                var success = wo.AddPhysicsObj();
                if (!success)
                {
                    Console.WriteLine($"AddWorldObjectInternal: couldn't spawn {wo.Name}");
                    return;
                }
            }

            // if adding a player to this landblock,
            // tell them about other nearby objects
            if (wo is Player)
            {
                var newlyVisible = wo.PhysicsObj.handle_visible_cells();
                wo.PhysicsObj.enqueue_objs(newlyVisible);
            }

            // broadcast to nearby players
            wo.NotifyPlayers();
        }