Exemplo n.º 1
0
    void Awake()
    {
        EntityID entityID = GetComponentInParent <EntityID>();

        weapon = entityID.gameObject;
        id     = entityID.id;

        collider   = GetComponent <Collider>();
        hitObjects = new List <GameObject>();
    }
Exemplo n.º 2
0
 public SpeedRingChallenge(EntityData data, Vector2 offset, EntityID id) : base(data.Position + offset)
 {
     ID              = id;
     nodes           = data.NodesOffset(offset);
     TimeLimit       = TimeSpan.FromSeconds(data.Float("timeLimit", 1f)).Ticks;
     ChallengeNameID = data.Attr("name", "fh_test");
     width           = data.Width;
     height          = data.Height;
     spawnBerry      = data.Bool("spawnBerry", true);
 }
Exemplo n.º 3
0
        public EntityId2(EntityID entityId, Type type)
        {
            EntityId = entityId;
            Type     = type;

            if (!type.IsSameOrSubclassOf(typeof(Entity)))
            {
                throw new ArgumentException("type must be Entity");
            }
        }
Exemplo n.º 4
0
        public Enemy(EntityID id, EntityType type, EffectPool fx, int damage, int maxHP, bool autoUpdate, int order, Sprite hurt, Sprite sprt, Animation anim, Vector2 colliderOffset, params ColliderBase[] colliders) : base(id, type, damage, maxHP, autoUpdate, order, sprt, anim, colliderOffset, colliders)
        {
            _deathFX = fx;

            _defaultSprite = sprt;
            _damageSprite  = hurt;

            _hurtTimer   = 0;
            _shouldFlash = false;
        }
Exemplo n.º 5
0
        private void AddChildren(EntityID entity, Registry registry)
        {
            var transformComponent = registry.GetComponent <TransformComponent>(entity);
            var parentEntity       = registry.GetEntityByTag(transformComponent.ParentTag);

            if (registry.TryGetComponent(parentEntity, out TransformComponent parentComponent))
            {
                parentComponent.AddChild(entity);
            }
        }
Exemplo n.º 6
0
 public DialogCutsceneTrigger(EntityData data, Vector2 offset, EntityID entId)
     : base(data, offset)
 {
     dialogEntry = data.Attr("dialogId");
     onlyOnce    = data.Bool("onlyOnce", true);
     endLevel    = data.Bool("endLevel", false);
     deathCount  = data.Int("deathCount", -1);
     triggered   = false;
     id          = entId;
 }
Exemplo n.º 7
0
        public LifeBerry(Vector2 position, EntityID id, bool AutoBubble) : base(position)
        {
            this.AutoBubble = AutoBubble;
            this.ID         = id;

            this.Collider = new Hitbox(14f, 14f, -7f, -7f);
            this.Add(new PlayerCollider(this.OnPlayer));
            this.Add(new MirrorReflection());
            this.Add(this.Follower = new Follower(this.ID, onLoseLeader: this.OnLoseLeader));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Attempts to update the parquet at the given position in the given layer.
        /// </summary>
        /// <param name="in_parquetID">The parquet to put.</param>
        /// <param name="in_position">The position to put the parquet in.</param>
        /// <param name="in_parquetLayer">The layer to put the parquet on.</param>
        /// <returns><c>true</c>, if the parquet was removed, <c>false</c> otherwise.</returns>
        private bool TrySetParquet(EntityID in_parquetID, Vector2Int in_position, EntityID[,] in_parquetLayer)
        {
            var result = false;

            if (IsValidPosition(in_position) && EntityID.None != in_parquetID)
            {
                in_parquetLayer[in_position.X, in_position.Y] = in_parquetID;
                result = true;
            }
            return(result);
        }
Exemplo n.º 9
0
 protected override void OnEntityDestroyed(Registry registry, EntityID entity)
 {
     if (registry.TryGetSingletonComponent(out PhysicsWorld2D physicsWorld))
     {
         if (registry.TryGetComponent(entity, out RigidBody2D rigidBody))
         {
             physicsWorld.World.DestroyBody(rigidBody.Body);
             Log.Print(physicsWorld.World.GetBodyCount());
         }
     }
 }
Exemplo n.º 10
0
 protected override void OnEntitySpawned(Registry registry, EntityID entity)
 {
     if (registry.TryGetSingletonComponent(out PhysicsWorld2D physicsWorld))
     {
         if (registry.TryGetComponent(entity, out TransformComponent transform) &&
             registry.HasComponent <RigidBody2D>(entity))
         {
             DefineBody(entity, registry, physicsWorld, transform);
         }
     }
 }
Exemplo n.º 11
0
        private static void PlayerOnRender(On.Celeste.Player.orig_Render orig, Player self)
        {
            orig(self);

            foreach (Follower follower in self.Leader.Followers)
            {
                Sprite sprite = follower.Entity.Get <Sprite>();
                if (sprite == null)
                {
                    continue;
                }

                EntityID id = default;
                switch (follower.Entity)
                {
                case Strawberry berry:
                    id = berry.ID;
                    break;

                case Key key:
                    id = key.ID;
                    break;
                }

                if (id.Equals(default(EntityID)))
                {
                    continue;
                }

                if (!Settings.TranslucentEnabled || !Settings.Enabled)
                {
                    if (HasChangedFollowEntities.Contains(id))
                    {
                        HasChangedFollowEntities.Remove(id);
                        sprite.Color = Color.White;
                    }

                    continue;
                }

                float distance = Vector2.Distance(follower.Entity.Position, self.Position) - Settings.TransparentRadius;
                if (distance < 0)
                {
                    distance = 0;
                }

                Color originalColor = sprite.Color;
                float alpha         = distance / Settings.TranslucentRadius;
                float approachAlpha = Calc.Approach(originalColor.A, 255 * alpha, 10f);
                sprite.Color = Color.White * (approachAlpha / 255f);

                HasChangedFollowEntities.Add(id);
            }
        }
Exemplo n.º 12
0
 /// <summary>
 /// Select a furnishing to paint with.
 /// </summary>
 /// <param name="in_furnishingID">The parquet ID to select.  Must represent a valid Furnishing.</param>
 public void SetFurnishingToPaint(EntityID in_furnishingID)
 {
     if (in_furnishingID.IsValidForRange(AssemblyInfo.FurnishingIDs))
     {
         _furnishingToPaint = in_furnishingID;
     }
     else
     {
         Error.Handle($"Cannot paint non-Furnishing {in_furnishingID} as if it were a Furnishing.");
     }
 }
Exemplo n.º 13
0
 public void AddItemToAlreadyTalkedAbout(EntityID ID)
 {
     for (int i = 0; i < this.alreadyTalkedAboutItems.Count; i++)
     {
         if (this.alreadyTalkedAboutItems[i] == ID)
         {
             return;
         }
     }
     this.alreadyTalkedAboutItems.Add(ID);
 }
Exemplo n.º 14
0
 /// <summary>
 /// Select a block to paint with.
 /// </summary>
 /// <param name="in_blockID">The parquet ID to select.  Must represent a valid Block.</param>
 public void SetBlockToPaint(EntityID in_blockID)
 {
     if (in_blockID.IsValidForRange(AssemblyInfo.BlockIDs))
     {
         _blockToPaint = in_blockID;
     }
     else
     {
         Error.Handle($"Cannot paint non-Block {in_blockID} as if it were a Block.");
     }
 }
Exemplo n.º 15
0
 public bool HaveIAlreadyDescribedThisItem(EntityID ID)
 {
     for (int i = 0; i < this.alreadyTalkedAboutItems.Count; i++)
     {
         if (this.alreadyTalkedAboutItems[i] == ID)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 16
0
        public Motion(EntityID origin, Vec3 targetLocation,
#if STATE_ADV
                      EntityAppearanceCollection appearance,
#endif
                      EntityLogic logic, byte[] serialLogic) : base(origin, targetLocation,
#if STATE_ADV
                                                                    appearance,
#endif
                                                                    logic, serialLogic)
        {
        }
Exemplo n.º 17
0
        public bool CheckR(string task, Vec3 taskLocation, EntityID currentEntityPosition)
        {
            float dist = GetDistance(taskLocation, currentEntityPosition.Position);

            if (dist <= Ranges.R)
            {
                return(true);
            }
            LogError(currentEntityPosition + ": " + task + " exceeded maximum range (" + Ranges.R + "): " + dist);
            return(false);
        }
Exemplo n.º 18
0
 /// <summary>
 /// Select a collectible to paint with.
 /// </summary>
 /// <param name="in_collectibleID">The parquet ID to select.  Must represent a valid Collectible.</param>
 public void SetCollectibleToPaint(EntityID in_collectibleID)
 {
     if (in_collectibleID.IsValidForRange(AssemblyInfo.CollectibleIDs))
     {
         _collectibleToPaint = in_collectibleID;
     }
     else
     {
         Error.Handle($"Cannot paint non-Collectible {in_collectibleID} as if it were a Collectible.");
     }
 }
Exemplo n.º 19
0
        public async Task <Chat> GetById(EntityID chatId)
        {
            var filter =
                Builders <Chat> .Filter.Where(
                    x => x.ChatID == chatId.ToString());

            var res = await chatsCollection.FindAsync(filter);

            var chat = res.FirstOrDefault();

            return(chat);
        }
Exemplo n.º 20
0
 /// <summary>
 /// Select a floor to paint with.
 /// </summary>
 /// <param name="in_floorID">The parquet ID to select.  Must represent a valid Floor.</param>
 public void SetFloorToPaint(EntityID in_floorID)
 {
     //Adds bounds-checking using the Ranges defined in Assembly.
     if (in_floorID.IsValidForRange(AssemblyInfo.FloorIDs))
     {
         _floorToPaint = in_floorID;
     }
     else
     {
         Error.Handle($"Cannot paint non-Floor {in_floorID} as if it were a Floor.");
     }
 }
Exemplo n.º 21
0
        public async Task <IList <Chat> > GetChatsForUser(EntityID user)
        {
            var filter =
                Builders <Chat> .Filter.Where(
                    x => x.Members.Contains(user.ToString()));

            var res = await chatsCollection.FindAsync(filter);

            var chat = res.ToList();

            return(chat);
        }
Exemplo n.º 22
0
        public async Task <Event> GetEventById(EntityID id)
        {
            var filter =
                Builders <Event> .Filter.Where(
                    x => x.Id.ToString() == id.LocalPart && x.OriginServer.ServerPart == id.ServerPart);

            var res = await events.FindAsync(filter);

            var ev = res.FirstOrDefault();

            return(ev);
        }
Exemplo n.º 23
0
        public virtual void OnSpawn(Spawner spawner, CharacterConfig config)
        {
            _spawnedBy = spawner;
            if (config != null)
            {
                _config = config;
            }

            Debug.Assert(Config != null);
            _entity = gameObject.AddComponent <EntityID>();
            _entity.SetID(Config.CharacterID);
        }
Exemplo n.º 24
0
 //销毁指定ID的Obj
 public void DestroyObject(EntityID ID)
 {
     for (int i = 0; i < this.updateList.Count; i++)
     {
         //  物理对象 && ID相等
         if (this.updateList[i] is PhysicalObject && (this.updateList[i] as PhysicalObject).entity.ID == ID)
         {
             this.updateList[i].Destroy();
             return;
         }
     }
 }
Exemplo n.º 25
0
        public DashFuseBox(EntityData data, Vector2 offset) : base(data.Position + offset, 4f, 16f, false)
        {
            string[] activationIds = data.Attr("activationIds", "").Split(',');

            _startCutscene = data.Bool("startCutscene", false);
            _persistent    = data.Bool("persistent", false);
            _id            = new EntityID(data.Level.Name, data.ID);
            _direction     = Direction.Right;
            Enum.TryParse(data.Attr("direction", "Right"), out _direction);

            Depth           = -20;
            Add(_mainSprite = new Sprite(GFX.Game, "objects/FactoryHelper/dashFuseBox/"));
            _mainSprite.Add("idle", "idle", 0.1f, "idleBackwards");
            _mainSprite.Add("chaos", "chaos", 0.08f, "chaos");
            _mainSprite.Add("idleBackwards", "idle", 0.1f, "idle", 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0);
            _mainSprite.Play("idle", false, false);

            _door = new Entity(Position)
            {
                Depth = 8490
            };
            _door.Add(_doorSprite = new Sprite(GFX.Game, "objects/FactoryHelper/dashFuseBox/"));
            _doorSprite.Add("busted", "busted", 0.05f);
            _doorSprite.Play("busted", false, false);
            _doorSprite.Active  = false;
            _doorSprite.Visible = false;


            if (_direction == Direction.Left)
            {
                _mainSprite.Scale *= new Vector2(-1f, 1f);
                //_mainSprite.Position.X += 4;
                _doorSprite.Scale      *= new Vector2(-1f, 1f);
                _doorSprite.Position.X += 4;

                Collider.Position.X -= 4;
                _pressDirection      = Vector2.UnitX;
                _sparks.Direction    = (float)Math.PI;
            }
            else
            {
                _pressDirection = -Vector2.UnitX;
            }

            foreach (string activationId in activationIds)
            {
                if (activationId != "")
                {
                    _activationIds.Add(activationId);
                }
            }
            OnDashCollide = OnDashed;
        }
Exemplo n.º 26
0
        public async Task <Chat> GetPrivateChat(EntityID u1, EntityID u2)
        {
            var filter =
                Builders <Chat> .Filter.Where(
                    x => x.Members.Contains(u1.ToString()) && x.Members.Contains(u2.ToString()) && x.Members.Length == 2 && x.IsPrivateChat);

            var res = await chatsCollection.FindAsync(filter);

            var chat = res.FirstOrDefault();

            return(chat);
        }
Exemplo n.º 27
0
        public BatterySwitch(Vector2 position, Sides side, bool persistent, bool allGates, bool alwaysFlag, EntityID id)
            : base(position, 0f, 0f, safe: true)
        {
            if (!particlesSetup)
            {
                SetupParticles();
                particlesSetup = true;
            }
            this.side       = side;
            this.persistent = persistent;
            this.allGates   = allGates;
            this.id         = id;
            this.alwaysFlag = alwaysFlag;
            Add(sprite      = BatteriesModule.SpriteBank.Create("battery_switch"));
            if (side == Sides.Up || side == Sides.Down)
            {
                base.Collider.Width  = 16f;
                base.Collider.Height = 8f;
            }
            else
            {
                base.Collider.Width  = 8f;
                base.Collider.Height = 16f;
            }
            switch (side)
            {
            case Sides.Up:
                sprite.Position = new Vector2(-2f, -2f);
                sprite.Rotation = (float)Math.PI / 2f;
                pressDirection  = Vector2.UnitY;
                startY          = base.Y;
                break;

            case Sides.Down:
                sprite.Position = new Vector2(18f, 10f);
                sprite.Rotation = -(float)Math.PI / 2f;
                pressDirection  = -Vector2.UnitY;
                break;

            case Sides.Right:
                sprite.Position = new Vector2(10f, 18f);
                sprite.FlipX    = true;
                pressDirection  = -Vector2.UnitX;
                break;

            case Sides.Left:
                sprite.Position = new Vector2(-2f, 18f);
                sprite.FlipX    = false;
                pressDirection  = Vector2.UnitX;
                break;
            }
        }
Exemplo n.º 28
0
        public void ctor(EntityData data, Vector2 offset, EntityID id)
        {
            orig_ctor(data, offset, id);

            constrainHeight = data.Bool("constrainHeight");

            Vector2[] nodes = data.NodesOffset(offset);
            if (nodes.Length >= 2)
            {
                top    = Math.Min(nodes[0].Y, nodes[1].Y);
                bottom = Math.Max(nodes[0].Y, nodes[1].Y);
            }
        }
Exemplo n.º 29
0
        public EntityContact(EntityID otherEntity, Contact contact)
        {
            if (contact is null)
            {
                throw new NullReferenceException(nameof(contact));
            }

            this.otherEntity = otherEntity;
            contact.GetWorldManifold(out var manifold);

            normal   = Util.UtilFunctions.FromVec2(manifold.Normal);
            location = Util.UtilFunctions.FromVec2(manifold.Points[0] * (World.Components.PhysicsWorld2D.PixelToMeter));
        }
Exemplo n.º 30
0
        public CustomNPC(EntityData data, Vector2 offset, EntityID id)
            : base(data.Position + offset)
        {
            this.id = id;

            spritePath          = data.Attr("sprite", ""); // Path is from Graphics/Atlases/Gameplay/characters
            spriteRate          = data.Float("spriteRate", 1f);
            dialogEntry         = data.Attr("dialogId", "");
            dialogs             = dialogEntry.Split(',');
            onlyOnce            = data.Bool("onlyOnce", true);
            endLevel            = data.Bool("endLevel", false);
            indicatorOffset.X   = data.Float("indicatorOffsetX", 0);
            indicatorOffset.Y   = data.Float("indicatorOffsetY", 0);
            approachWhenTalking = data.Bool("approachWhenTalking", false);
            approachDistance    = data.Int("approachDistance", 16);

            if (data.Bool("flipX", false))
            {
                scale.X = -1;
            }
            if (data.Bool("flipY", false))
            {
                scale.Y = -1;
            }

            if (!string.IsNullOrEmpty(spritePath))
            {
                string extension = Path.GetExtension(spritePath);
                if (!string.IsNullOrEmpty(extension))
                {
                    spritePath = spritePath.Replace(extension, "");
                }
                spritePath = Path.Combine("characters", spritePath).Replace('\\', '/');
                name       = Regex.Replace(spritePath, "\\d+$", string.Empty);

                textures = GFX.Game.GetAtlasSubtextures(name);
                if (textures != null && textures.Count > 1)
                {
                    animated = true;
                }
            }
            else
            {
                // spritePath is empty: we don't want any sprite.
                spritePath = null;
                name       = null;
                textures   = null;
            }

            frame = 0;
        }
 protected MyBarthsMoonMissionBase(MyMissionID id, StringBuilder debugName, MyTextsWrapperEnum name, MyTextsWrapperEnum decription, MyMissionID[] requiredMissions, EntityID[] buildContainers, EntityID locationEntity)
 {            
     ID = id;
     DebugName = debugName;
     Name = name;
     Description = decription;
     RequiredMissions = requiredMissions;            
     Location = new MyMissionLocation(baseSector, (uint)locationEntity);
     m_buildedContainers = buildContainers;
     m_objectives = new List<MyObjective>();
     Flags = MyMissionFlags.Story;
 }
 protected static void HideDummy(EntityID platformId) 
 {
     SetDummyVisibleStatus(platformId, false);
 }
 protected static void ShowDummy(EntityID platformId) 
 {
     SetDummyVisibleStatus(platformId, true);
 }
 private MyEntity GetEntity(EntityID entityId)
 {
     return MyScriptWrapper.GetEntity((uint)entityId);
 }
 protected static void SetDummyVisibleStatus(EntityID platformId, bool visible) 
 {
     SetDummyVisibleStatus((MyDummyPoint)MyScriptWrapper.GetEntity((uint)platformId), visible);            
 }
 protected static void ShowContainer(EntityID containerId) 
 {
     SetContainerVisibleStatus(containerId, true);
 }
 protected static void HideContainer(EntityID containerId) 
 {
     SetContainerVisibleStatus(containerId, false);
 }
 protected static void SetContainerVisibleStatus(EntityID containerId, bool visible) 
 {
     SetContainerVisibleStatus((MyPrefabContainer)MyScriptWrapper.GetEntity((uint)containerId), visible);            
 }
 protected MyEntity GetEntity(EntityID entityId)
 {
     return MyScriptWrapper.GetEntity((uint)entityId);
 }
 protected void HideDetectorAndPlatformAndContainer(EntityID detectorId, EntityID platformId, EntityID containerId) 
 {
     HideDummy(detectorId);
     HideDummy(platformId);
     if (m_buildedContainers == null || !m_buildedContainers.Contains(containerId))
     {                
         HideContainer(containerId);
     }
 }