Exemplo n.º 1
0
        private void DataGrid_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Delete)
            {
                var dataGrid = (DataGrid)sender;

                if (dataGrid.SelectedItems.Count > 0)
                {
                    NetObject netObject   = (NetObject)dataGrid.SelectedItems[0];
                    int       recipientId = 0;
                    if (netObject.GetType() == typeof(Project))
                    {
                        recipientId = 12;
                    }
                    else if (netObject.GetType() == typeof(Todo))
                    {
                        recipientId = 10;
                    }
                    else
                    {
                        throw new Exception("Unknown New Type");
                    }

                    DataItemDeleted data = new DataItemDeleted()
                    {
                        PK   = netObject.pId,
                        Type = netObject.GetType().ToString()
                    };

                    tornado14Observer.Send(new Package(SENDERID, recipientId, (int)EventMapping.DataItemDeleted_19, Method.DELETE, XmlSerializationHelper.Serialize(data)));
                }
            }
        }
Exemplo n.º 2
0
    private void Start()
    {
        _netObject = GetComponent <NetObject>();
        _agent     = GetComponent <NavMeshAgent>();

        _agent.speed = MoveSpeed;
    }
Exemplo n.º 3
0
        public virtual void Awake()
        {
            if (_proxy == null)
            {
                _proxy = this;
            }

            GetAllowedTypesFromHashes();

            PollInterfaces();

            netObj      = transform.GetParentComponent <NetObject>();
            syncContact = GetComponent <ISyncContact>();

            /// Associate a group assign with this component.
            contactGroupsAssign = GetComponent <ContactGroupAssign>();
            // If no group assign on this node, find parent and use that if set to apply to children
            if (ReferenceEquals(contactGroupsAssign, null))
            {
                var found = transform.GetNestedComponentInParent <IContactGroupsAssign, NetObject>();
                if (found != null && found.ApplyToChildren)
                {
                    contactGroupsAssign = found;
                }
            }

            // cache the mask of ContactTypes that will be responded to
            foreach (IOnContactEvent cb in OnContactEventCallbacks)
            {
                usedContactTypes |= cb.TriggerOn;
            }
        }
Exemplo n.º 4
0
        public override void __awake(GameObject pluginOwner)
        {
            base.__awake(pluginOwner);

            myNetObject = pluginOwner.GetComponent <NetObject>();
            UID         = Utils.Library.GetHashString(this.ToString()); //TODO: more efficient hash function?
        }
Exemplo n.º 5
0
                public void Create(NetObject _Parent)
                {
                    #region Prepare the object to do work.
                    Parent = _Parent;
                    if (Parent.UserObject.IsUtilityUser())
                    {
                        HostSocket = null;
                    }
                    else
                    {
                        HostSocket = Server.CreateHostMainframe();
                    }

                    if ((!(Parent.UserObject.IsUtilityUser())) && HostSocket == null)
                    {
                        //NOT a utility user, but the host service is closed.
                        Parent.ClientObject.SendMessage("There was an error connecting you to the server: The host server is offline.");
                        Parent.ClientObject.SendMessage("Please come back later! :D");
                        Parent.Close();
                        Logger.Console.WriteLine("&cCONNECTING USER WAS DISCONNECTED BECAUSE THE HOST SERVICE IS UNREACHABLE.");
                        return;
                    }

                    ReceiveThread = new Thread(new ThreadStart(ReceiveLoop));
                    //Do not start until the parent tells us to by calling ReceiveThread.Start();
                    #endregion
                }
Exemplo n.º 6
0
 public void OnPreNetDestroy(NetObject rootNetObj)
 {
     if (rootNetObj == netObj)
     {
         DismountAll();
     }
 }
    protected override void OnHandleMessage(NetDataReader reader)
    {
        int unitCount = reader.GetInt();

        for (int i = 0; i < unitCount; i++)
        {
            UnitData unitData = MessageSerializerService.DeserializeObjectOfType <UnitData>(reader.GetString());

            UnitController newUnit = ((GameObject)Instantiate(Resources.Load("Objects/Player"),
                                                              new Vector3(unitData.PositionData.X, unitData.PositionData.Y, unitData.PositionData.Z),
                                                              Quaternion.identity)).GetComponent <UnitController>();

            NetObject netObject = newUnit.gameObject.GetComponent <NetObject>();
            netObject.Id = unitData.UnitId;

            newUnit.Health       = unitData.Health;
            newUnit.MoveSpeed    = unitData.MoveSpeed;
            newUnit.MinDamage    = unitData.MinDamage;
            newUnit.MaxDamage    = unitData.MaxDamage;
            newUnit.AttackRadius = unitData.AttackRadius;

            ClientNetEventListener.Instance.NetObjects.Add(unitData.UnitId, netObject);
            BattleManager.Instance.EnemyUnits.Add(i, newUnit);
        }

        BattleManager.Instance.StartSession();
    }
Exemplo n.º 8
0
        public static PlaceBoardPacket BuildFromBoard(CircuitBoard board, Transform parent)
        {
            var netObj = board.GetComponent <NetObject>();

            if (netObj == null)
            {
                netObj       = board.gameObject.AddComponent <NetObject>();
                netObj.NetID = NetObject.GetNewID();
            }

            var packet = new PlaceBoardPacket
            {
                AuthorID      = NetworkClient.Instance.PlayerID,
                ParentBoardID = parent?.GetComponent <NetObject>()?.NetID ?? 0,
                Position      = board.transform.position,
                EulerAngles   = board.transform.eulerAngles
            };
            var savedObj = SavedObjectUtilities.CreateSavedObjectFrom(board.gameObject);

            using (var mem = new MemoryStream())
            {
                BinFormatter.Serialize(mem, savedObj);

                packet.SavedBoard = mem.ToArray();
            }

            return(packet);
        }
Exemplo n.º 9
0
        public static PlaceComponentPacket BuildFromLocalComponent(GameObject component)
        {
            var netObj = component.GetComponent<NetObject>();

            if (netObj == null)
            {
                netObj = component.AddComponent<NetObject>();
                netObj.NetID = NetObject.GetNewID();
                
                if (component.GetComponent<ObjectInfo>()?.ComponentType == ComponentType.Mount)
                {
                    var board = component.GetComponentInChildren<CircuitBoard>();
                    board.gameObject.AddComponent<NetObject>().NetID = NetObject.GetNewID();
                }
            }

            var objInfo = component.GetComponent<ObjectInfo>();

            int parentId = component.transform.parent?.GetComponent<NetObject>()?.NetID ?? 0;

            return new PlaceComponentPacket
            {
                NetID = netObj.NetID,
                SavedObject = SavedObjectUtilities.CreateSavedObjectFrom(objInfo),
                LocalPosition = component.transform.localPosition,
                EulerAngles = component.transform.localEulerAngles,
                ParentBoardID = parentId
            };
        }
Exemplo n.º 10
0
        /// <summary>
        /// Delete a query from the stored service.
        /// </summary>
        /// <param name="comms">
        /// <see cref="IGbdxComms"/> used for communicating with the stored query service.
        /// </param>
        /// <param name="netObject">
        /// the network object to be used in communicating with stored query service
        /// </param>
        /// <returns>
        /// True if the delete query method is successful.
        /// </returns>
        public bool DeleteQuery(IGbdxComms comms, NetObject netObject)
        {
            try
            {
                // Login in prior to sending a delete
                if (!comms.AuthenticateNetworkObject(ref netObject))
                {
                    return(false);
                }

                // Send the delete request to the service.
                var output = comms.DeleteRequest(netObject);

                // Check the response status code
                if (output.ResponseStatusCode != HttpStatusCode.NoContent && output.ResponseStatusCode != HttpStatusCode.OK)
                {
                    return(false);
                }
            }
            catch
            {
                // Any errors occur return false.
                return(false);
            }

            // Everything is all good.
            return(true);
        }
Exemplo n.º 11
0
        public static void UpdateStates(CircuitStatePacket packet)
        {
            foreach (var state in packet.States)
            {
                var netObj = NetObject.GetByNetId(state.Key.Key);

                if (netObj == null || !netObj.enabled)
                {
                    continue;
                }

                var ios = netObj.GetComponentsInChildren <CircuitOutput>();

                if (ios.Length <= state.Key.Value)
                {
                    continue;
                }

                var io = ios[state.Key.Value];

                CurrentlyUpdating = io;
                io.On             = state.Value;
            }

            CurrentlyUpdating      = null;
            HasCalledCircuitUpdate = true;
        }
Exemplo n.º 12
0
        protected virtual NetObject EnsureComponentsDependenciesExist()
        {
            if (!netObj)
            {
                netObj = transform.GetParentComponent <NetObject>();
            }

            if (netObj)
            {
                photonView = netObj.GetComponent <PhotonView>();

                //if (this is IContactSystem)
                //	if (ReferenceEquals(netObj.GetComponent<IContactTrigger>(), null))
                //		netObj.gameObject.AddComponent<ContactTrigger>();

                RigidbodyType = (netObj.Rb) ? RigidbodyType.RB : (netObj.Rb2D) ? RigidbodyType.RB2D : RigidbodyType.None;

                return(netObj);
            }
            else
            {
                Debug.LogError("NetComponent derived class cannot find a NetObject on '" + transform.root.name + "'.");
                return(null);
            }
        }
    public message MakeMessageFromClip()
    {
        message sound = new message("sendSound");

        audioSource.clip = aud;
        float[] samples = new float[audioSource.clip.samples * audioSource.clip.channels];
        audioSource.clip.GetData(samples, 0);
        int       cpt      = 0;
        NetObject subSound = new NetObject("subSound");

        subSound.addInt("", samples.Length);

        for (int i = 0; i < samples.Length; i++)
        {
            if (cpt == 250)
            {
                sound.addNetObject(subSound);
                subSound = new NetObject("subSound");
                cpt      = 0;
            }
            subSound.addFloat("", (Mathf.Floor(samples[i] * 1000) / 1000));
            cpt++;
        }
        return(sound);
    }
Exemplo n.º 14
0
        public void StagedRequestTest()
        {
            var netObj = new NetObject
            {
                BaseUrl      = "https://iipbeta.digitalglobe.com",
                Password     = "******",
                User         = "******",
                AuthEndpoint = "/cas/oauth/token",
                AddressUrl   =
                    "/insight-vector/api/esri/OSM/Polygon/Building/paging?left=36.2845510828066&upper=35.6019997390785&right=37.529485081057&lower=34.6768653000117&ttl=1m&count=100"
            };

            var testClass = new GbdxComms();

            var result = testClass.Request(netObj);

            var pageID = VectorIndexHelper.GetPageId(result.Result);

            netObj.PageId     = pageID;
            netObj.AddressUrl = "/insight-vector/api/esri/paging";

            // Set the form parameters for paged requests.
            var formParams = HttpUtility.ParseQueryString(string.Empty);

            formParams.Add("ttl", "1m");
            formParams.Add("fields", "attributes");
            formParams.Add("pagingId", netObj.PageId);

            var result2 = testClass.StagedRequest(ref netObj, formParams);
        }
Exemplo n.º 15
0
        public object ToType(Type conversionType, IFormatProvider provider)
        {
            NetObject no = new NetObject();

            no.pId = pId;
            return(no);
        }
Exemplo n.º 16
0
        public static void Done()
        {
            var       noisemaker = NoisemakerMenu.NoisemakerBeingEdited;
            NetObject netObj     = null;

            try
            {
                netObj = noisemaker.transform.parent.GetComponent <NetObject>();
            }
            catch (System.NullReferenceException) { }

            if (netObj == null)
            {
                return;
            }

            Network.SendPacket(new ComponentDataPacket
            {
                NetID         = netObj.NetID,
                ComponentType = ComponentType.Noisemaker,
                Data          = new List <object>
                {
                    noisemaker.ToneFrequency
                }
            });
        }
Exemplo n.º 17
0
        public void ShouldCreateNetObjectInstance()
        {
            var       prefab   = AssetDatabase.LoadAssetAtPath <NetObject>("Assets/Netling/Tests/Editor/NetObject.prefab");
            NetObject instance = prefab.Create(0, 0, 0, Vector3.zero, Quaternion.identity);

            Assert.NotNull(instance);
        }
Exemplo n.º 18
0
        private void DataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            NetObject netObject = (NetObject)e.Row.Item;

            if (netObject != null && e.Column.SortMemberPath != null)
            {
                int recipientId = 0;
                if (e.Row.Item.GetType() == typeof(Project))
                {
                    recipientId = 12;
                }
                else if (e.Row.Item.GetType() == typeof(Todo))
                {
                    recipientId = 10;
                }
                else
                {
                    throw new Exception("Unknown New Type");
                }
                DataItemChanged data = new DataItemChanged()
                {
                    PK           = netObject.pId,
                    PropertyName = e.Column.SortMemberPath,
                    Value        = ((TextBox)e.EditingElement).Text,
                    Type         = netObject.GetType().ToString()
                };

                tornado14Observer.Send(new Package(SENDERID, recipientId, (int)EventMapping.DataItemChanged_13, Method.PUT, XmlSerializationHelper.Serialize(data)));
            }
            else
            {
                throw new Exception("Todo or Property Name is Empty.");
            }
        }
Exemplo n.º 19
0
        private void tcpAsyncServer_ReceiveServerEvent(object sender, ReceiveServerEventArgs e)
        {
            this.Invoke((EventHandler)(delegate
            {
                NetPacket np = (NetPacket)e.netPacket;
                switch (np.PacketHead.PType)
                {
                case NetPacket.NetPacketType.STRING:
                    textBox1.AppendText("收到字符串" + np.Data.ToString() + "\r\n");
                    tcpAsyncServer.Send(e.Client, NetPacket.MakeStringPacket("服务器收到数据" + np.Data.ToString()));
                    break;

                case NetPacket.NetPacketType.BINARY:
                    NetFile nf = (NetFile)np.Data;
                    textBox1.AppendText("收到文件" + nf.FileName + ",正在后台生成.....\r\n");
                    string file = System.Windows.Forms.Application.StartupPath + "\\收到的文件\\" + nf.FileName;
                    FileInfo f = new FileInfo(file);
                    if (!Directory.Exists(f.DirectoryName))
                    {
                        Directory.CreateDirectory(f.DirectoryName);
                    }
                    FileStream fs = null;
                    fs = new FileStream(file, FileMode.Create);
                    fs.BeginWrite(nf.Content, 0, nf.Content.Length, NetFileWriteOK, fs);
                    break;

                case NetPacket.NetPacketType.COMPLEX:
                    NetObject no = (NetObject)np.Data;
                    textBox1.AppendText("收到序列对象" + no.TypeName + ",正在后台生成.....\r\n");
                    break;
                }
            }));
        }
Exemplo n.º 20
0
        public static void DoPaint(PaintBoardPacket packet)
        {
            var obj   = NetObject.GetByNetId(packet.BoardID).gameObject;
            var board = obj.GetComponent <CircuitBoard>();

            board.SetBoardColor(packet.Color);
        }
Exemplo n.º 21
0
        protected NetObject EnsureComponentsDependenciesExist()
        {
            if (!netObj)
            {
                netObj = GetComponentInParent <NetObject>();
            }

            if (netObj)
            {
#if PUN_2_OR_NEWER
                pv = netObj.GetComponent <PhotonView>();
#endif
                if (this is IContacting)
                {
                    if (ReferenceEquals(netObj.GetComponent <IContactTrigger>(), null))
                    {
                        netObj.gameObject.AddComponent <ContactTrigger>();
                    }
                }

                RigidbodyType = (netObj.Rb) ? RigidbodyType.RB : (netObj.Rb2D) ? RigidbodyType.RB2D : RigidbodyType.None;

                return(netObj);
            }
            else
            {
                Debug.LogError("NetComponent derived class cannot find a NetObject on '" + transform.root.name + "'.");
                return(null);
            }
        }
Exemplo n.º 22
0
        public static void DoData(ComponentDataPacket packet)
        {
            var netObj = NetObject.GetByNetId(packet.NetID);

            if (netObj == null)
            {
                return;
            }

            switch (packet.ComponentType)
            {
            case ComponentType.Noisemaker:
                var noisemaker = netObj.GetComponentInChildren <Noisemaker>();
                noisemaker.ToneFrequency = (float)packet.Data[0];

                break;

            case ComponentType.Display:
                var display = netObj.GetComponentInChildren <Display>();
                display.DisplayColor = (DisplayColor)packet.Data[0];
                display.ForceVisualRefresh();

                break;

            case ComponentType.Label:
                var label = netObj.GetComponent <Label>();
                label.text.text     = (string)packet.Data[0];
                label.text.fontSize = (float)packet.Data[1];

                break;
            }
        }
Exemplo n.º 23
0
        public static PlaceWirePacket BuildFromLocalWire(Wire wire)
        {
            var wireBeingPlaced = wire.gameObject;

            var netObj = wireBeingPlaced.AddComponent <NetObject>();

            netObj.NetID = NetObject.GetNewID();

            var netObj1 = GetNetObjectFromPoint(wire.Point1);
            var netObj2 = GetNetObjectFromPoint(wire.Point2);

            if (netObj1 == null || netObj2 == null)
            {
                return(null);
            }

            int ioIndex1 = netObj1.IO.IndexOf(wire.Point1.parent.gameObject);
            int ioIndex2 = netObj2.IO.IndexOf(wire.Point2.parent.gameObject);

            if (ioIndex1 == -1 || ioIndex2 == -1)
            {
                return(null);
            }

            return(new PlaceWirePacket
            {
                NetObj1Id = netObj1.NetID,
                NetObj2Id = netObj2.NetID,
                Point1Id = ioIndex1,
                Point2Id = ioIndex2,
                NetID = netObj.NetID
            });
        }
Exemplo n.º 24
0
        public static void PlaceBoard()
        {
            if (StuffPlacer.OkayToPlace)
            {
                foreach (var item in BoardPlacer.BoardBeingPlaced.GetComponentsInChildren <ObjectInfo>())
                {
                    var netObj = item.GetComponent <NetObject>() ?? item.gameObject.AddComponent <NetObject>();
                    netObj.NetID = NetObject.GetNewID();
                }

                foreach (var item in BoardPlacer.BoardBeingPlaced.GetComponentsInChildren <NetObject>())
                {
                    item.enabled = true;
                }

                var boardComp = BoardPlacer.BoardBeingPlaced.GetComponent <CircuitBoard>();
                var parent    = BoardPlacer.ReferenceObject.transform.parent;

                var packet = PlaceBoardPacket.BuildFromBoard(boardComp, parent);

                Network.SendPacket(packet);

                foreach (var item in boardComp.GetComponentsInChildren <CircuitOutput>())
                {
                    CircuitStatePacket.SetOutputState(item, item.On, true);
                }
            }
        }
Exemplo n.º 25
0
        public static void DoneMenu(EditDisplayColorMenu __instance)
        {
            var       display = __instance.DisplayBeingEdited;
            NetObject netObj  = null;

            try
            {
                netObj = display.transform.parent.GetComponent <NetObject>();
            }
            catch (System.NullReferenceException) { } //No, I can't null check

            if (netObj == null)
            {
                return;
            }

            Network.SendPacket(new ComponentDataPacket
            {
                NetID         = netObj.NetID,
                ComponentType = ComponentType.Display,
                Data          = new List <object>
                {
                    display.DisplayColor
                }
            });
        }
Exemplo n.º 26
0
 protected override void Write(NetOutgoingMessage message)
 {
     message.Write((ushort)Items.Count);
     foreach (var obj in Items)
     {
         NetObject.WriteToMessage(obj, message);
     }
 }
Exemplo n.º 27
0
 public static List <NetObject> Include(this List <NetObject> List, NetObject IncludeThis)
 {
     if (!(List.Contains(IncludeThis)))
     {
         List.Add(IncludeThis);
     }
     return(List);
 }
Exemplo n.º 28
0
 public void UpdatePos()
 {
     for (int i = 0; i < listBall.Count; i++)
     {
         NetObject ball = listBall[i];
         ball.PerformMove();
     }
 }
Exemplo n.º 29
0
        private IValue AtKey(List <IValue> arguments, Scope s)
        {
            ListNode       list   = (ListNode)arguments[0];
            NetObject      netObj = (NetObject)list.Children[1].Eval(s);
            IdentifierNode index  = (IdentifierNode)list.Children[2];

            return(netObj.Get(index.Name));
        }
Exemplo n.º 30
0
        public static NetPacket GetPacket(byte[] buffer)
        {
            if (buffer.Length < NetPacketHead.HEAD_SIZE)
            {
                throw (new Exception("数据包长度过短,无法转换"));
            }
            if (buffer.Length < (NetPacketHead.HEAD_SIZE + BitConverter.ToInt32(buffer, 8)))
            {
                throw (new Exception("数据包长度过短,无法转换"));
            }
            Int32 version = BitConverter.ToInt32(buffer, 0);//协议号

            if (version != NetPacketHead.Version)
            {
                throw (new Exception("数据协议版本号不符!"));
            }
            NetPacket     packet     = new NetPacket();
            NetPacketHead packetHead = new NetPacketHead();

            packetHead.PType   = (NetPacketType)BitConverter.ToInt32(buffer, sizeof(Int32));//封包类型
            packetHead.Len     = BitConverter.ToInt32(buffer, sizeof(Int32) + sizeof(Int32));
            packet._packetHead = packetHead;

            Byte[] packetBuffer = new Byte[packetHead.Len];
            Array.Copy(buffer, NetPacketHead.HEAD_SIZE, packetBuffer, 0, packetHead.Len);
            switch (packetHead.PType)
            {
            case NetPacketType.STRING:
                packet.Data = encoding.GetString(packetBuffer);
                break;

            case NetPacketType.BINARY:
                NetFile f           = new NetFile();
                int     filenamelen = BitConverter.ToInt32(packetBuffer, 0);//文件名长度
                f.FileName = encoding.GetString(packetBuffer, sizeof(Int32), filenamelen);
                f.Content  = new Byte[packetBuffer.Length - sizeof(Int32) - filenamelen];
                Array.Copy(packetBuffer, sizeof(Int32) + filenamelen, f.Content, 0, f.Content.Length);
                packet.Data = f;
                break;

            case NetPacketType.COMPLEX:
                NetObject no          = new NetObject();
                int       typenamelen = BitConverter.ToInt32(packetBuffer, 0);//文件名长度
                no.TypeName = NetPacket.encoding.GetString(packetBuffer, sizeof(Int32), typenamelen);

                byte[] Content = new Byte[packetBuffer.Length - sizeof(Int32) - typenamelen];
                Array.Copy(packetBuffer, sizeof(Int32) + typenamelen, Content, 0, Content.Length);

                MemoryStream mStream = new MemoryStream();
                mStream.Write(Content, 0, Content.Length);
                mStream.Position = 0;
                no.gragh         = BinarySerializeHelper.DeSerialize(mStream);
                mStream.Close();
                packet.Data = no;
                break;
            }
            return(packet);
        }
    public message MakeMessageFromClip()
    {
        message sound = new message("sendSound");

        audioSource.clip = aud;
        float[] samples = new float[audioSource.clip.samples * audioSource.clip.channels];
        audioSource.clip.GetData(samples, 0);
        int cpt = 0;
        NetObject subSound = new NetObject("subSound");
        subSound.addInt("", samples.Length);

        for (int i = 0; i < samples.Length; i++) {
            if (cpt == 250) {
                sound.addNetObject(subSound);
                subSound = new NetObject("subSound");
                cpt = 0;
            }
            subSound.addFloat("", (Mathf.Floor(samples[i] * 1000) / 1000));
            cpt++;
        }
        return sound;
    }
 public message MakeMessageFromImage(TendresseData image)
 {
     message img = new message("sendImage");
     for (int i = 0; i < image.pointList.Count; i++)
     {
         NetObject lineObj = new NetObject("");
         List<Vector3> line = image.pointList[i];
         for (int j = 0; j < line.Count; j++)
         {
             lineObj.addFloat("", line[j].x);
             lineObj.addFloat("", line[j].y);
         }
         img.addNetObject(lineObj);
     }
     return img;
 }
Exemplo n.º 33
0
    //Tags iself and generates a reference to its stats.
    public override void Start()
    {
        //rigidbody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;
        gameObject.tag = "netObject";
        netObject = this;
        objectStats = gameObject.GetComponent<ObjectStats>();

        gameObject.layer = LayerMask.NameToLayer("netObject");

        base.Start();
    }
Exemplo n.º 34
0
        public override Single GetUpdatePriority(NetObject scopeObject, UInt64 updateMask, Int32 updateSkips)
        {
            if (Parent == null || !(scopeObject is GhostObject) || (scopeObject as GhostObject).Parent == null)
                return updateSkips * 0.02f;

            var otherParent = (scopeObject as GhostObject).Parent;

            if (otherParent.GetTargetObject() != Parent && otherParent != Parent && otherParent != Parent.Owner && (Parent.GetAsCreature() == null ||
                    (Parent.GetAsCreature().GetSummonOwner() != otherParent.GetTFID())))
            {
                var otherAvPos = otherParent.GetAvatarPosition();
                var thisAvPos = Parent.GetAvatarPosition();

                var val = (Single) Math.Sqrt((otherAvPos.X - thisAvPos.X) * (otherAvPos.X - thisAvPos.X) + (otherAvPos.Y - thisAvPos.Y) * (otherAvPos.Y - thisAvPos.Y));
                return UpdatePriorityScalar *
                        (((1.0F -
                            (val / ((otherParent.GetMap().GetNumberOfTerrainGridsPerObjectGrid() * 100.0F) * 1.2F))) *
                            0.5F) + (updateSkips * 0.001F));
            }

            return 1.0f;
        }
Exemplo n.º 35
0
 public Boolean IsGhostVIsibleToMe(NetObject ghost)
 {
     return OwningConnection != null && OwningConnection.GetGhostIndex(ghost) != -1;
 }
Exemplo n.º 36
0
 public void AddGhost(TNLConnection conn, NetObject ghost)
 {
     Ghosts.Add(conn.GetPlayerCOID(), ghost);
 }