Example #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="netManager">The network manager owning this player.</param>
        /// <param name="netWorld">Network world owning this player.</param>
        /// <param name="steamId">The steam id of the player.</param>
        public NetLocalPlayer(NetManager netManager, NetWorld netWorld, Steamworks.CSteamID steamId) : base(netManager, netWorld, steamId)
        {
            GameDoorsManager.Instance.onDoorsOpen = () => {
                Messages.OpenDoorsMessage msg = new Messages.OpenDoorsMessage();
                msg.open = true;
                netManager.BroadcastMessage(msg, Steamworks.EP2PSend.k_EP2PSendReliable);
            };

            GameDoorsManager.Instance.onDoorsClose = () => {
                Messages.OpenDoorsMessage msg = new Messages.OpenDoorsMessage();
                msg.open = false;
                netManager.BroadcastMessage(msg, Steamworks.EP2PSend.k_EP2PSendReliable);
            };

            GameCallbacks.onObjectPickup = (GameObject gameObj) => {
                Messages.PickupObjectMessage msg = new Messages.PickupObjectMessage();
                msg.netId = netWorld.GetPickupableNetId(gameObj);
                netManager.BroadcastMessage(msg, Steamworks.EP2PSend.k_EP2PSendReliable);
            };

            GameCallbacks.onObjectRelease = (bool drop) => {
                Messages.ReleaseObjectMessage msg = new Messages.ReleaseObjectMessage();
                msg.drop = drop;
                netManager.BroadcastMessage(msg, Steamworks.EP2PSend.k_EP2PSendReliable);
            };
        }
Example #2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="netManager">The network manager owning this player.</param>
        /// <param name="netWorld">Network world owning this player.</param>
        /// <param name="steamId">The steam id of the player.</param>
        public NetLocalPlayer(NetManager netManager, NetWorld netWorld, Steamworks.CSteamID steamId) : base(netManager, netWorld, steamId)
        {
            GameDoorsManager.Instance.onDoorsOpen = (GameObject door) => {
                Messages.OpenDoorsMessage msg = new Messages.OpenDoorsMessage();
                msg.position = Utils.GameVec3ToNet(door.transform.position);
                msg.open     = true;
                netManager.BroadcastMessage(msg, Steamworks.EP2PSend.k_EP2PSendReliable);
            };

            GameDoorsManager.Instance.onDoorsClose = (GameObject door) => {
                Messages.OpenDoorsMessage msg = new Messages.OpenDoorsMessage();
                msg.position = Utils.GameVec3ToNet(door.transform.position);
                msg.open     = false;
                netManager.BroadcastMessage(msg, Steamworks.EP2PSend.k_EP2PSendReliable);
            };

            GameCallbacks.onObjectPickup = (GameObject gameObj) => {
                Messages.PickupObjectMessage msg = new Messages.PickupObjectMessage();
                msg.netId = netWorld.GetPickupableNetId(gameObj);
                Client.Assert(msg.netId != NetPickupable.INVALID_ID, "Tried to pickup not network pickupable.");
                netManager.BroadcastMessage(msg, Steamworks.EP2PSend.k_EP2PSendReliable);
            };

            GameCallbacks.onObjectRelease = (bool drop) => {
                Messages.ReleaseObjectMessage msg = new Messages.ReleaseObjectMessage();
                msg.drop = drop;
                netManager.BroadcastMessage(msg, Steamworks.EP2PSend.k_EP2PSendReliable);
            };

            BeerCaseManager.Instance.onBottleConsumed = (GameObject bcase) => {
                Messages.RemoveBottleMessage msg = new Messages.RemoveBottleMessage();
                msg.netId = netWorld.GetPickupableNetId(bcase);
                Client.Assert(msg.netId != NetPickupable.INVALID_ID, "Tried to drink from not network beercase.");
                netManager.BroadcastMessage(msg, Steamworks.EP2PSend.k_EP2PSendReliable);
            };

            LightSwitchManager.Instance.onLightSwitchUsed = (GameObject lswitch, bool turnedOn) => {
                Messages.LightSwitchMessage msg = new Messages.LightSwitchMessage();
                msg.pos    = Utils.GameVec3ToNet(lswitch.transform.position);
                msg.toggle = turnedOn;
                netManager.BroadcastMessage(msg, Steamworks.EP2PSend.k_EP2PSendReliable);
            };

            if (animManager == null)
            {
                animManager = new PlayerAnimManager();
            }
        }