コード例 #1
0
        // TODO: clean up the casting in this method
        public bool EntityInteraction(NewPackets.EntityInteraction parameters)
        {
            //Debug.Log($"Entity Interaction | E1: {FactionID} {parameters.myEntityIndex} | E2: {parameters.otherFactionIndex} {parameters.otherEntityIndex}!");

            ICarrier carrier = Entities[parameters.myEntityIndex] as ICarrier;

            if (carrier == null)
            {
                return(false);
            }

            if (parameters.otherFactionIndex == 0)                                                      // Entity is in the neutral faction (pickup)
            {
                carrier.Carry(GameManager.PlayerFactions[0].Entities[parameters.otherEntityIndex]);
            }
            else if (parameters.otherFactionIndex == FactionID)                                         // Entity is in own faction
            {
                if (parameters.myEntityIndex == parameters.otherEntityIndex)                            // "self click" defines a pop-deploy request
                {
                    carrier.TryDeploy();
                }
                else                                                                                    // Otherwise pass
                {
                    carrier.Pass(Entities[parameters.otherEntityIndex]);
                }
            }

            return(true);
        }